constitution · epochs · watch · epoch 3

comparison

c_af08bd851e49 (tommy-mor) vs c_8dc1a8119370 (tommy-mor)

download prompt · raw event · cmp_ff2b59d4d900bc

council reasoning

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

Side B removes ~1800 lines of a fragile, over-engineered keystroke-transition parser graph (with its brittle race-condition test) and replaces it with a small, testable, deterministic paste-and-go URL parser plus a simpler UI, net reducing complexity and fixing a stated reliability problem. Side A adds real functionality (a pairwise vote-compare page, bridge-pair selection logic, id normalization) but is more feature-churn/addition without removing prior debt, and 'refactor' as commit message undersells substantial new surface area added without corresponding cleanup elsewhere.

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

A lands core product surface: a full /vote compare page, bridge-first pair selection in pair.rs, in-place morph of edge history after record_vote, ItemId::from_storage normalization, and integration/browser coverage. B’s paste-and-go rewrite correctly deletes an unreliable ~1.8k-line keystroke graph and race workarounds, but that is a navigation UX simplification, not new ranking/voting capability of comparable lasting depth.

openai/gpt-chat-latest · winner A · 5:1 · permalink

Side A adds substantial new functionality: a dedicated pairwise voting page, pair-selection logic that prioritizes bridging disconnected ranking components, in-place UI morphing after votes, canonicalized item ID parsing to fix Reddit URL inconsistencies, and extensive unit/integration tests. Side B mainly removes a large autocomplete/parser system in favor of a simpler paste-and-go flow and redirect, simplifying the UI but largely replacing existing behavior rather than adding lasting project capabilities.

sides

A — c_af08bd851e49 (tommy-mor)

message

[2bc302c3] refactor

diff preview

diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index 06001212820101e0cc953d3687dea64f85e60787..d2f9769108def7ca2c5857aec8b4319426188a66 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -47,7 +47,7 @@ pub async fn post_ui_html(
             ratio_left,
             ratio_right,
             scope,
-            next,
+            vote_compare,
         } => {
             let parent = parent_from_scope(&scope);
             if let Err(e) = state
@@ -57,14 +57,12 @@ pub async fn post_ui_html(
                 return ui_js_warn(&e).into_response();
             }
             let tree = state.tree.read().await;
-            if !next.trim().is_empty() {
+            if vote_compare {
+                let left = parse_item_param(&a);
+                let right = parse_item_param(&b);
+                let morph = crate::html::vote::vote_recorded_morph(&tree, &parent, &left, &right);
                 drop(tree);
-                return JsBuilder::new()
-                    .raw(&format!(
-                        "window.location.href={};",
-                        js_string_literal(next.trim())
-                    ))
-                    .into_response();
+                return morph.into_response();
             }
             let empty = crate::reducer::NodeState::default();
             let node = tree.get(&parent).unwrap_or(&empty);
@@ -137,7 +135,7 @@ mod tests {
                 ratio_left: 3,
                 ratio_right: 1,
                 scope: String::new(),
-                next: String::new(),
+                vote_compare: false,
             }
         );
     }
diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs
index 61cdbc094819ddedb755572c59456ec0d6617619..cd578a5fea46a9a1d49e238d08a80c2caf18708d 100644
--- a/server/src/html/mod.rs
+++ b/server/src/html/mod.rs
@@ -65,6 +65,15 @@ impl JsBuilder {
         self
     }
 
+    pub(crate) fn morph_inner_selector(mut self, selector: &str, markup: Markup) -> Self {
+        let html = js_string_literal(&markup.into_string());
+        self.snippets.push(format!(
+            "var __el = document.querySelector({sel}); if (__el) {{ Idiomorph.morph(__el, {html}, {{ morphStyle: 'innerHTML' }}); }}",
+            sel = js_string_literal(selector),
+        ));
+        self
+    }
+
     pub(crate) fn raw(mut self, js: &str) -> Self {
         if !js.is_empty() {
             self.snippets.push(js.to_string());
diff --git a/server/src/html/vote.rs b/server/src/html/vote.rs
new file mode 100644
index 0000000000000000000000000000000000000000..89ed621ad861214e147add2062224fc4137ff8ad
--- /dev/null
+++ b/server/src/html/vote.rs
@@ -0,0 +1,306 @@
+//! Pairwise vote UI — `/vote?parent=` with optional `left` / `right`.
+
+use axum::{
+    extract::{Query, State},
+    response::{Html, IntoResponse},
+};
+use maud::{html, Markup};
+use serde::Deserialize;
+
+use crate::{
+    form_template::template_json_compact,
+    html::JsBuilder,
+    pair::{children_of, resolve_pair, suggest_next_pair_in_pool},
+    path_types::ItemId,
+    reducer::{GlobalTree, GroupState, NodeState, VoteData},
+    state::{parse_item_param, AppState},
+    ui_action::UI_RPC_FIELD,
+};
+
+use super::{breadcrumb_path, item_href, layout};
+
+#[derive(Debug, Deserialize)]
+pub struct VoteQuery {
+    pub parent: String,
+    #[serde(default)]
+    pub left: Option<String>,
+    #[serde(default)]
+    pub right: Option<String>,
+}
+
+pub fn vote_href(parent: &ItemId) -> String {
+    format!(
+        "/vote?parent={}",
+        urlencoding::encode(parent.as_str())
+    )
+}
+
+fn vote_compare_href(parent: &ItemId, left: &ItemId, right: &ItemId) -> String {
+    format!(
+        "/vote?parent={}&left={}&right={}",
+        urlencoding::encode(parent.as_str()),
+        urlencoding::encode(left.as_str()),
+        urlencoding::encode(right.as_str()),
+    )
+}
+
+fn display_label(id: &ItemId) -> String {
+    id.segments()
+        .last()
+        .map_or("item".into(), |v| v.to_string())
+}
+
+fn child_title(tree: &GlobalTree, id: &ItemId) -> String {
+    tree.get(id)
+        .and_then(|n| n.data.as_ref())
+        .map(|d| d.title.clone())
+        .unwrap_or_else(|| display_label(id))
+}
+
+fn ratio_pct(ratio_left: i32, ratio_right: i32) -> f64 {
+    let l = ratio_left.max(0) as f64;
+    let r = ratio_right.max(0) as f64;
+    let sum = l + r;
+    if sum <= 0.0 {
+        50.0
+    } else {
+        (l / sum) * 100.0
+    }
+}
+
+fn ratios_for_page(v: &VoteData, page_left: &ItemId, page_right: &ItemId) -> (i32, i32) {
+    match (v.a.as_str(), v.b.as_str()) {
+        (a, b) if a == page_left.as_str() && b == page_right.as_str() => {
+            (v.ratio_left, v.ratio_right)
+        }
+        (a, b) if a == page_right.as_str() && b == page_left.as_str() => {
+            (v.ratio_right, v.ratio_left)
+        }
+        _ => (v.ratio_left, v.ratio_right),
+    }
+}
+
+fn edge_votes(group: &GroupState, left: &ItemId, right: &ItemId) -> Vec<VoteData> {
+    group
+        .recent_votes
+        .iter()
+        .filter(|v| {
+            (v.a.as_str() == left.as_str() && v.b.as_str() == right.as_str())
+                || (v.a.as_str() == right.as_str() && v.b.as_str() == left.as_str())
+        })
+        .cloned()
+        .collect()
+}
+
+fn vote_edge_history(tree: &GlobalTree, group: &GroupState, left: &ItemId, right: &ItemId) -> Markup {
+    let mut votes = edge_votes(group, left, right);
+    votes.sort_by(|a, b| b.ts.cmp(&a.ts));
+    let legend_left = child_title(tree, left);
+    let legend_right = child_title(tree, right);
+    html! {
+        @if votes.is_empty() {
+            p class="muted vote-edge-empty" { "no votes on this pair yet" }
+        } @else {
+            h3 class="vote-edge-history-title" {
+                "votes on this pair"
+                span class="vote-edge-history-axis muted" { " · " (legend_left) " : " (legend_right) }
+            }
+            ul class="vote-edge-history" {
+                @for v in &votes {
+                    @let (r_left, r_right) = ratios_for_page(v, left, right);
+                    @let pct = ratio_pct(r_left, r_right);
+                    li class="vote-edge-history-row" {
+                        div class="vote-edge-meta" {
+                            span class="vote-edge-ratio" { (format!("{}:{}", r_left, r_right)) }
+                        }
+                        div class="ratio-bar vote-edge-bar" aria-hidden="true" {
+                            div class="ratio-left" style={(format!("width: {:.3}%;", pct))} {}
+                            div class="ratio-right" style={(format!("width: {:.3}%;", 100.0 - pct))} {}
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+fn vote_back_nav(parent: &ItemId) -> Markup {
+    html! {
+        div class="vote-compare-nav" {
+            a class="vote-compare-back muted" href=(item_href(parent)) { "← back to " (display_label(parent)) }
+        }
+    }
+}
+
+fn vote_compare_actions(parent: &ItemId, next: Option<&(ItemId, ItemId)>) -> Markup {
+    let next_href = next.map(|(l, r)| vote_compare_href(parent, l, r));
+    html! {
+        div id="vote-compare-actions" class="vote-compare-actions" {
+            button type="submit" class="btn-primary" data-testid="vote-post" { "post vote" }
+            @if let Some(href) = &next_href {
+                a class="btn-secondary vote-compare-next" data-testid="vote-next-pair" href=(href) { "next pair" }
+            } @else {
+                span class="btn-secondary vote-compare-next is-disabled" { "no next pair" }
+            }
+        }
+    }
+}
+
+/// After recording a vote on the compare page: refresh edge history and next-pair link.
+pub(crate) fn vote_recorded_morph(
+    tree: &GlobalTree,
+    parent: &ItemId,
+    left: &ItemId,
+    right: &ItemId,
+) -> JsBuilder {
+    let pool = children_of(tree, parent);
+    let empty = NodeState::default();
+    let group = tree
+        .get(parent)
+        .unwrap_or(&empty)
+        .local_ranking
+        .clone();
+    let edge_history = vote_edge_history(tree, &group, left, right);
+    let next_pair = suggest_next(&group, left, right, &pool);
+    let actions = vote_compare_actions(parent, next_pair.as_ref());
+    JsBuilder::new()
+        .morph_inner_selector("#vote-edge-history-region", edge_history)
+        .morph_selector("#vote-compare-actions", actions)
+}
+
+fn vote_compare_item_card(tree: &GlobalTree, item: &ItemId, side_class: &str) -> Markup {
+    let href = item_href(item);
+    let title = child_title(tree, item);
+    html! {
+        div class=(format!("vote-compare-side {side_class}")) {
+            a class=(format!("vote-compare-item {side_class}")) href=(href) {
+                @if let Some(row) = crate::render::reddit::child_row_markup(tree, item, &href) {
+                    (row)
+                } @else {
+                    strong { (title) }
+                }
+            }
+            @if let Some(node) = tree.get(item) {
+                @if crate::render::reddit::is_reddit_post(item) {
+                    @if let Some(data) = &node.data {
+                        @if let Some(src) = data.image_url.as_ref().or(data.thumb_url.as_ref()) {
+                            figure class="vote-compare-figure" {
+                                img class="vote-compare-image" src=(src) alt="" loading="lazy";
+                            }
+                        }
+                        @if let Some(author) = &data.author {
+                            p class="muted small" { "by " (author) }
+                        }
+                    }
+                } @else if let Some(data) = &node.data {
+                    @if let Some(body) = &data.body_html {
+                        div class="vote-compare-item-body" {
+                            (maud::PreEscaped(body))
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
+
+
+fn suggest_next(group: &GroupState, left: &ItemId, right: &ItemId, pool: &[ItemId]) -> Option<(ItemId, ItemId)> {
+    suggest_next_pair_in_pool(group, pool, Some((left, right)))
+}
+
+pub async fn vote_page(
+    State(state): State<AppState>,
+    Query(q): Query<VoteQuery>,
+) -> impl IntoResponse {
+    let parent = parse_item_param(&q.parent);
+    let left_param = q.left.as_deref().map(parse_item_param);
+    let right_param = q.right.as_deref().map(parse_item_param);
+
+    let tree = state.tree.read().await;
+    let empty = NodeState::default();
+    let parent_node = tree.get(&parent).unwrap_or(&empty);
+
+    let (left, right) = match resolve_pair(
+        &tree,
+        &parent,
+        left_param.as_ref(),
+        right_param.as_ref(),
+    ) {
+        Ok(p) => p,
+        Err(e) => {
+            let (msg, status) = e.status_message();
+            return (status, msg).into_response();
+        }
+    };
+
+    let pool = children_of(&tree, &parent);
+    let group = &parent_node.local_ranking;
+    let next_pair = suggest_next(group, &left, &right, &pool);
+    let edge_history = vote_edge_history(&tree, group, &left, &right);
+
+    let rpc_json = template_json_compact(&serde_json::json!({
+        "action": "record_vote",
+        "a": left.as_str(),
+        "b": right.as_str(),
+        "ratio_left": {"$form:i32": "ratio_left"},
+        "ratio_right": {"$form:i32": "ratio_right"},
+        "scope": parent.as_str(),
+        "vote_compare": true,
+    }))
+    .expect("vote rpc json");
+
+    let title = format!(
+        "vote — {} vs {}",
+        child_title(&tree, &left),
+        child_title(&tree, &right)
+    );
+
+    let body = html! {
+        section class="vote-compare-shell" {
+            h1 { "compare" }
+            (breadcrumb_path(&parent))
+            p class="muted vote-compare-scope" {
+                "ranking children of "
+                a href=(item_href(&par

… preview truncated; 32,381 characters omitted

download full diff A

B — c_8dc1a8119370 (tommy-mor)

message

[529cc941] Replace autocomplete parser with paste-and-go navigate.

The keystroke transition graph was unreliable; a textarea plus Go button now parses pasted Reddit URLs and redirects to the subreddit ranking scope.

Co-authored-by: Cursor <cursoragent@cursor.com>

diff preview

diff --git a/AGENTS.md b/AGENTS.md
index 77f2e31d4e860a92a77255ca5106c8b6c4510ee7..36ee4c0ec700bffbe226ee775ba9cf59cf35c770 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -11,7 +11,6 @@ Single Rust web app **`sorter2-server`**: pairwise voting, rank-centrality ranki
 - **Rust 1.88+** is required (some transitive crates need a recent Cargo). The image may ship older `/usr/local/cargo` (1.83); use **rustup** and `rustup default 1.88.0` before building.
 - **System packages** for builds: `pkg-config`, `libssl-dev` (for `reqwest` / OpenSSL in integration tests and release builds).
 - **Clojure CLI 1.12.0.1530** (optional but used in CI): install from https://clojure.org/guides/install_clojure — needed for `./scripts/clj-test.sh` / Kaocha tests.
-- **Playwright browser** for the spel browser test (`test/parser_race.clj`): install once with `clojure -M -e "(com.microsoft.playwright.CLI/main (into-array String [\"install\" \"chromium\" \"--with-deps\"]))"`. The browser binary is cached under `~/.cache/ms-playwright`.
 
 ### Commands (see also `TEST.sh`)
 
diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index 1339048c955c0a3eb5120381aaf031424cbed540..c4ab9d65c7b3cd42a5b4d093ba429993c101e9a8 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -8,7 +8,7 @@ use std::collections::HashMap;
 use crate::{
     html::{js_string_literal, ranking_panel, JsBuilder},
     parser::parse_reddit_url,
-    parser_render::parser_panel_morph,
+    parser_render::navigate_panel,
     state::AppState,
     ui_action::{parse_html_ui_from_form, HtmlUiAction},
 };
@@ -57,18 +57,23 @@ pub async fn post_ui_html(
                 .morph_selector("#ranking-panel", panel)
                 .into_response()
         }
-        HtmlUiAction::ParseQuery { query } => {
-            let action = parse_reddit_url(&query);
-            let panel = parser_panel_morph(&query, &action);
-            let mut js = JsBuilder::new().morph_selector("#parser-panel", panel);
-            if let Some(comp) = action.primary_completion() {
-                js = js.raw(&format!(
-                    "var __pi=document.getElementById('parser-input'); if(__pi){{__pi.dataset.completion={};}}",
-                    js_string_literal(comp)
-                ));
+        HtmlUiAction::ParseQuery { query } => match parse_reddit_url(&query) {
+            Ok(subreddit) => {
+                let dest = format!("/?sub={subreddit}");
+                JsBuilder::new()
+                    .raw(&format!(
+                        "window.location.href={};",
+                        js_string_literal(&dest)
+                    ))
+                    .into_response()
             }
-            js.into_response()
-        }
+            Err(message) => {
+                let panel = navigate_panel(&query, Some(&message));
+                JsBuilder::new()
+                    .morph_selector("#parser-panel", panel)
+                    .into_response()
+            }
+        },
     }
 }
 
diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs
index 94a5cfb561d1c8464bd2782f7ffd4e0965ccf95d..9650d333d29c4ac94ceb407aee3ee00399c7f40b 100644
--- a/server/src/html/mod.rs
+++ b/server/src/html/mod.rs
@@ -11,8 +11,7 @@ use serde::Deserialize;
 
 use crate::{
     form_template::template_json_compact,
-    parser_action::ParserAction,
-    parser_render::parser_panel,
+    parser_render::navigate_panel,
     ranking::{top_bottom, RankedItem},
     reducer::GroupState,
     state::{normalize_scope, AppState},
@@ -336,10 +335,9 @@ pub async fn home(
     let empty = GroupState::new();
     let group = groups.get(&scope).unwrap_or(&empty);
 
-    let empty_action = ParserAction::suggest(String::new(), None);
     let body = html! {
         h1 { "sorter2" }
-        (parser_panel("", &empty_action))
+        (navigate_panel("", None))
         (vote_panel(&scope))
         (ranking_panel(&scope, group))
     };
diff --git a/server/src/lib.rs b/server/src/lib.rs
index fa423640d598f4ba97a5885d228e78d7b97f7a22..de8bca48cbf689cad22337883e7791966e7c4919 100644
--- a/server/src/lib.rs
+++ b/server/src/lib.rs
@@ -4,7 +4,6 @@ pub mod events;
 pub mod form_template;
 pub mod html;
 pub mod parser;
-pub mod parser_action;
 pub mod parser_render;
 pub mod path_types;
 pub mod ranking;
diff --git a/server/src/parser.rs b/server/src/parser.rs
index ea437c4434045b44cba04a2b3416df850db518e7..50571a59f0d3ece1e2538f88e00ef46ec40ea545 100644
--- a/server/src/parser.rs
+++ b/server/src/parser.rs
@@ -1,1811 +1,87 @@
-use std::collections::HashMap;
-use std::sync::OnceLock;
+//! Extract a subreddit name from a pasted Reddit URL or path.
 
-use crate::parser_action::{GuideOption, ParserAction, ScrollingSuggestion, Suggestion};
-
-// --- Core Abstractions ---
-
-/// Unique identifier for nodes in the graph
-type NodeId = &'static str;
-
-/// Pattern matching for edges
-#[derive(Debug, Clone)]
-pub enum EdgePattern {
-    /// Matches exact literal string
-    Literal(&'static str),
-    
-    /// Matches any prefix of a string and suggests the full string
-    /// e.g., PrefixOf("reddit.com") matches "r", "re", "red", "reddit", "reddit.com"
-    PrefixOf(&'static str),
-    
-    /// Captures a variable segment (e.g., subreddit name, username)
-    Variable(&'static str),
-    
-    /// Matches any string (wildcard)
-    Any,
-}
-
-impl EdgePattern {
-    /// Try to match this pattern against input, return (consumed_chars, captured_value)
-    fn matches(&self, input: &str) -> Option<(usize, Option<String>)> {
-        match self {
-            EdgePattern::Literal(lit) => {
-                if input.starts_with(lit) {
-                    Some((lit.len(), None))
-                } else {
-                    None
-                }
-            }
-            EdgePattern::PrefixOf(target) => {
-                // Check if input is a prefix of target
-                if target.starts_with(input) && !input.is_empty() {
-                    // It's a valid prefix
-                    Some((input.len(), None))
-                } else if input.starts_with(target) {
-                    // Full match
-                    Some((target.len(), None))
-                } else {
-                    None
-                }
-            }
-            EdgePattern::Variable(var_name) => {
-                // Consume until next '/' or end of string
-                let end = input.find('/').unwrap_or(input.len());
-                if end > 0 {
-                    let captured = input[..end].to_string();
-                    // Validate based on variable type
-                    if is_valid_variable(var_name, &captured) {
-                        Some((end, Some(captured)))
-                    } else {
-                        None
-                    }
-                } else {
-                    None
-                }
-            }
-            EdgePattern::Any => {
-                // Match everything until next '/' or end
-                let end = input.find('/').unwrap_or(input.len());
-                if end > 0 {
-                    Some((end, Some(input[..end].to_string())))
-                } else {
-                    None
-                }
-            }
-        }
-    }
-    
-    /// Get the completion suggestion for this pattern
-    fn completion(&self, partial: &str) -> Option<String> {
-        match self {
-            EdgePattern::PrefixOf(target) => {
-                if target.starts_with(partial) && partial != *target {
-                    Some(target.to_string())
-                } else {
-                    None
-                }
-            }
-            _ => None,
-        }
+pub fn parse_reddit_url(query: &str) -> Result<String, String> {
+    let q = query.trim();
+    if q.is_empty() {
+        return Err("Paste a Reddit URL or r/subreddit path".into());
     }
-}
 
-/// Edge in the graph
-pub struct Edge {
-    pattern: EdgePattern,
-    target: NodeId,
-    /// Optional description for autocomplete
-    description: Option<&'static str>,
-}
-
-/// Handler function for generating UI actions (Send + Sync so the graph can live in `OnceLock`).
-type Handler = Box<dyn Fn(&str, &str, &HashMap<String, String>) -> ParserAction + Send + Sync>;
-
-/// Node in the graph
-pub struct Node {
-    #[allow(dead_code)]
-    id: NodeId,
-    edges: Vec<Edge>,
-    handler: Option<Handler>,
-}
-
-/// The composable parser graph (immutable after `build`).
-pub struct Graph {
-    nodes: HashMap<NodeId, Node>,
-    root: NodeId,
-}
-
-// --- Graph Builder (Fluent API) ---
-
-pub struct GraphBuilder {
-    nodes: HashMap<NodeId, Node>,
-    current_node: Option<NodeId>,
-    root: NodeId,
-}
-
-impl GraphBuilder {
-    pub fn new() -> Self {
-        let mut nodes = HashMap::new();
-        nodes.insert(
-            "root",
-            Node {
-                id: "root",
-                edges: Vec::new(),
-                handler: None,
-            },
-        );
-
-        GraphBuilder {
-            nodes,
-            current_node: Some("root"),
-            root: "root",
-        }
+    if let Some(sub) = subreddit_after_prefix(q, "r/") {
+        return Ok(sub);
     }
 
-    /// Select a node to add edges to
-    pub fn at(mut self, node_id: NodeId) -> Self {
-        self.nodes.entry(node_id).or_insert_with(|| Node {
-            id: node_id,
-            edges: Vec::new(),
-            handler: None,
-        });
-        self.current_node = Some(node_id);
-        self
+    if let Some(sub) = subreddit_from_path_segment(q, "/r/") {
+        return Ok(sub);
     }
-    
-    /// Add an edge from the current node
-    pub fn edge(self, pattern: EdgePattern, target: NodeId) -> Self {
-        self.edge_with_desc(pattern, target, None)
-    }
-    
-    /// Add an edge with description
-    pub fn edge_with_desc(
-        mut self,
-        pattern: EdgePattern,
-        target: NodeId,
-        desc: Option<&'static str>,
-    ) -> Self {
-        let current = self.current_node.expect("No current node selected");
-
-        self.nodes.entry(target).or_insert_with(|| Node {
-            id: target,
-            edges: Vec::new(),
-            handler: None,
-        });
-
-        if let Some(node) = self.nodes.get_mut(current) {
-            node.edges.push(Edge {
-                pattern,
-                target,
-                description: desc,
-            });
-        }
 
-        self
-    }
-
-    /// Set handler for current node
-    pub fn handler<F>(mut self, handler: F) -> Self
-    where
-        F: Fn(&str, &str, &HashMap<String, String>) -> ParserAction + Send + Sync + 'static,
-    {
-        let current = self.current_node.expect("No current node selected");
-        if let Some(node) = self.nodes.get_mut(current) {
-            node.handler = Some(Box::new(handler));
-        }
-        self
-    }
-    
-    /// Build the final graph
-    pub fn build(self) -> Graph {
-        Graph {
-            nodes: self.nodes,
-            root: self.root,
-        }
-    }
+    Err("Could not find a subreddit in that URL".into())
 }
 
-// --- Parser Implementation ---
-
-impl Graph {
-    pub fn parse(&self, input: &str) -> ParserAction {
-        let normalized = input.trim().to_lowercase();
-        let mut state = ParserState {
-            input: &normalized,
-            cursor: 0,
-            current_node_id: self.root,
-            context: HashMap::new(),
-            original_query: input.to_string(),
-            current_prefix: String::new(),
-        };
-        
-        self.parse_recursive(&mut state)
-    }
-    
-    fn parse_recursive(&self, state: &mut ParserState) -> ParserAction {
-        let node = self
-            .nodes
-            .get(state.current_node_id)
-            .expect("Node not found in graph");
-
-        // If we've consumed all input, check for handler or suggestions
-        if state.cursor >= state.input.len() {
-            if let Some(handler) = &node.han

… preview truncated; 92,533 characters omitted

download full diff B

Hardlinks — judgments / attempts / prompt

prompt download

judgments

attempts

Prompt text is loaded only by the download route.