constitution · epochs · watch · epoch 3

comparison

c_f6d0fed9bf9a (tommy-mor) vs c_88200cfa5c4d (tommy-mor)

download prompt · raw event · cmp_424b873f7af230

council reasoning

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

Side A is a chaotic 'seed' dump with files placed at the repo root (not real source paths) and several .rs files literally containing pasted terminal output (e.g. 'tommy@Tommys-Laptop:...⇒ cat server/src/form_template.rs') mixed into the code, meaning much of it wouldn't even compile as committed — it reads like a snapshot rather than a working change. Side B is a small, precise, correctness-preserving clippy cleanup that fixes real issues (a silently-skipped test missing #[test], correct is_some_and usage, cleaner error destructuring) with no risk of regression, making it the more trustworthy, lasting contribution despite its modest size.

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

Side A seeds substantial core logic (rank-centrality implementation with tests, reducer state machine, form-template filling, vote-compare UI, and a large composable parser) that defines lasting project behavior, while Side B only applies minor clippy cleanups, a missing #[test] attribute, and allow(dead_code) with no functional design or bugfix impact.

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

Side A introduces substantial new project functionality: core modules for ranking and reducer state, a graph-based parser with extensive tests, browser UI plumbing (bundle.js and UI actions), voting pages, form-template handling, and test scripts. Side B is limited to maintenance—adding one missing #[test], silencing dead-code warnings, and making small Clippy-driven cleanups (pattern simplifications, type aliasing, API idioms)—which improves code quality but does not add comparable lasting capabilities.

sides

A — c_f6d0fed9bf9a (tommy-mor)

message

[1d9d8ade] init seed

diff preview

diff --git a/TEST.sh b/TEST.sh
new file mode 100755
index 0000000000000000000000000000000000000000..266b71f29259f5c2cad2617476ebe2ebc9596d39
--- /dev/null
+++ b/TEST.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cargo test --all
+./scripts/clj-test.sh
diff --git a/bundle.js b/bundle.js
new file mode 100644
index 0000000000000000000000000000000000000000..8d316f9a57cc7c379fe4bd8e42e092c7eac5d265
--- /dev/null
+++ b/bundle.js
@@ -0,0 +1,52 @@
+/**
+ * Slug web UI: only plumbing — fetch/eval/SSE. No product UI logic here.
+ */
+(function () {
+  function evalJs(js) {
+    if (js && String(js).trim()) {
+      eval(js);
+    }
+  }
+
+  // Theme cookie sync (runs before paint; full reload if localStorage disagrees with cookie)
+
+  function initSlugUi() {
+    // POST forms → eval response (except theme + full-navigation forms)
+    document.addEventListener('submit', async function (e) {
+      var f = e.target;
+      if (!f || f.tagName !== 'FORM') return;
+      if ((f.method || 'get').toLowerCase() !== 'post') return;
+      if (f.id === 'slug-theme-form') return;
+      if (f.getAttribute('data-navigate') === 'full') return;
+      e.preventDefault();
+      var resp = await fetch(f.action, {
+        method: 'POST',
+        body: new URLSearchParams(new FormData(f)),
+        headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
+        credentials: 'same-origin',
+      });
+      evalJs(await resp.text());
+    });
+
+    // SSE: server-pushed JS
+    function connectSSE() {
+      var ssePath = window.location.pathname + window.location.search;
+      var es = new EventSource('/sse?path=' + encodeURIComponent(ssePath));
+      es.onmessage = function (e) {
+        evalJs(e.data);
+      };
+      es.onerror = function () {
+        es.close();
+        setTimeout(connectSSE, 3000);
+      };
+    }
+    connectSSE();
+  }
+
+  if (document.readyState === 'loading') {
+    document.addEventListener('DOMContentLoaded', initSlugUi);
+  } else {
+    initSlugUi();
+  }
+})();
+
diff --git a/clj-test.sh b/clj-test.sh
new file mode 100755
index 0000000000000000000000000000000000000000..b62a49b98ed60a65a46807b7ad80fa3142f14952
--- /dev/null
+++ b/clj-test.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -euo pipefail
+cd "$(dirname "$0")/.."
+mkdir -p target
+exec clojure -M:kaocha
diff --git a/forms.rs b/forms.rs
new file mode 100644
index 0000000000000000000000000000000000000000..d509fd889fde3fed2662ce0a39006b7a51ae762a
--- /dev/null
+++ b/forms.rs
@@ -0,0 +1,145 @@
+tommy@Tommys-Laptop:~/programming/slug-star/slug|main ⇒  cat server/src/form_template.rs
+//! Plan2-style JSON templates with `{"$form": "field_name"}` holes, filled from
+//! `application/x-www-form-urlencoded` (or any `String` → `String` map) **before**
+//! deserializing into a typed struct.
+//!
+//! # Wire format
+//!
+//! Templates are **compact JSON** (`serde_json::to_string`): one line, no pretty
+//! printing, strings escaped per JSON rules (`\"`, `\n`, etc.). Embed that string
+//! in HTML attributes or text nodes with normal HTML escaping (e.g. maud), not
+//! bespoke encodings.
+//!
+//! # Power vs flat hidden fields
+//!
+//! A form is always a string→string map. You can fake depth with dotted keys (`a.b.c`),
+//! but one structured blob (`__rpc__` = compact JSON) gives you nested objects,
+//! arrays, and optional fields without inventing a new naming scheme each time.
+//!
+//! # Security
+//!
+//! Substitution runs **before** `serde` into your command type. It does not fix
+//! authorization: if the client can replace the hidden `__rpc__` value, they can
+//! change the command shape unless you validate (signed blob, server-side session
+//! context, or treat the blob as hints only). Same threat model as any hidden field.
+
+use serde::Serialize;
+use serde_json::Value;
+use std::collections::HashMap;
+
+/// Serialize a value to compact JSON for a hidden `__rpc__` (or similar) field.
+pub fn template_json_compact<T: Serialize>(v: &T) -> serde_json::Result<String> {
+    serde_json::to_string(v)
+}
+
+/// Recursively walk the JSON AST and replace `{"$form": "key"}` with the submitted
+/// string for `key` (empty if missing). Other keys are unchanged.
+pub fn substitute_form_vars(val: &mut Value, form_data: &HashMap<String, String>) {
+    match val {
+        Value::Object(map) => {
+            if map.len() == 1 {
+                if let Some(Value::String(field_name)) = map.get("$form") {
+                    let submitted = form_data
+                        .get(field_name.as_str())
+                        .map(|s| s.as_str())
+                        .unwrap_or("");
+                    *val = Value::String(submitted.to_string());
+                    return;
+                }
+            }
+            for v in map.values_mut() {
+                substitute_form_vars(v, form_data);
+            }
+        }
+        Value::Array(arr) => {
+            for v in arr.iter_mut() {
+                substitute_form_vars(v, form_data);
+            }
+        }
+        _ => {}
+    }
+}
+
+/// Parse JSON, apply [`substitute_form_vars`], return the mutated value.
+pub fn fill_template_from_form(
+    template_json: &str,
+    form_data: &HashMap<String, String>,
+) -> Result<Value, serde_json::Error> {
+    let mut v: Value = serde_json::from_str(template_json)?;
+    substitute_form_vars(&mut v, form_data);
+    Ok(v)
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use serde::Deserialize;
+
+    #[derive(Debug, Deserialize, PartialEq, Eq)]
+    struct Demo {
+        room: String,
+        thread_tag: String,
+        nested: Nested,
+    }
+
+    #[derive(Debug, Deserialize, PartialEq, Eq)]
+    struct Nested {
+        text: String,
+    }
+
+    #[test]
+    fn holes_become_strings() {
+        let json = r#"{
+            "room": "public",
+            "thread_tag": {"$form": "tag"},
+            "nested": {"text": {"$form": "body"}}
+        }"#;
+        let mut form = HashMap::new();
+        form.insert("tag".into(), "foo".into());
+        form.insert("body".into(), "hello\nworld".into());
+
+        let v = fill_template_from_form(json, &form).unwrap();
+        let d: Demo = serde_json::from_value(v).unwrap();
+        assert_eq!(
+            d,
+            Demo {
+                room: "public".into(),
+                thread_tag: "foo".into(),
+                nested: Nested {
+                    text: "hello\nworld".into(),
+                },
+            }
+        );
+    }
+
+    #[test]
+    fn missing_form_key_is_empty_string() {
+        let json = r#"{"x": {"$form": "nope"}}"#;
+        let mut form = HashMap::new();
+        form.insert("other".into(), "y".into());
+        let v = fill_template_from_form(json, &form).unwrap();
+        assert_eq!(v["x"], "");
+    }
+
+    #[test]
+    fn array_of_holes() {
+        let json = r#"{"items": [{"$form": "a"}, {"$form": "b"}]}"#;
+        let mut form = HashMap::new();
+        form.insert("a".into(), "1".into());
+        form.insert("b".into(), "2".into());
+        let v = fill_template_from_form(json, &form).unwrap();
+        assert_eq!(v["items"], serde_json::json!(["1", "2"]));
+    }
+
+    #[test]
+    fn template_json_compact_escapes_and_single_line() {
+        let s = template_json_compact(&serde_json::json!({
+            "x": "quote\"and\nnewline"
+        }))
+        .unwrap();
+        assert!(!s.contains('\n'));
+        assert!(s.contains("\\\"") || s.contains("\\n"));
+    }
+}
+tommy@Tommys-Laptop:~/programming/slug-star/slug|main ⇒  
+
diff --git a/gameifying.tdsl b/gameifying.tdsl
new file mode 100644
index 0000000000000000000000000000000000000000..93d2a61d94fcba4370c82d9612e6bb0f0318cc15
--- /dev/null
+++ b/gameifying.tdsl
@@ -0,0 +1,2 @@
+consider gating certain views (top all time?) by a 10 day usage streak.. or something like that. 
+or like a path, on homepage(?), that shows day 1: r/amitheasshole, day2: r/aww, day3: gaming, or something like that.  progressive revelation + usage incentive.
diff --git a/pagerank_streaming.tdsl b/pagerank_streaming.tdsl
new file mode 100644
index 0000000000000000000000000000000000000000..0f2231b94936c17610adf653ca26b0faa6f2ac3a
--- /dev/null
+++ b/pagerank_streaming.tdsl
@@ -0,0 +1,11 @@
+eventually i want to have ranking histories.
+like "visionary" and "fraud" waxing and waning in a uplot graph over time for #elon-musk. 
+there are too many query combinations to precomupte the ranking histories 
+(arbitrary user filters, and tag overlap combinations maybe), 
+so we're just going to have to calculate them all on demand. 
+computers are fast, its okay. for each vote, we need to calculate rank centrality again. 
+i was thinking, for n votes we calculate the rank centrality, 
+and get node weights. we then output that data to the client (over websocket, or testable barrier). 
+then we calculate n+1 votes, _but we keep the node weights in memory_ 
+so the rank centrality process converges faster. 
+this also has the side effect of making the ranking stream in satisfyingly as you load the page.
diff --git a/parser.rs b/parser.rs
new file mode 100644
index 0000000000000000000000000000000000000000..2b87b974f8d1dd93bee35681d87668a94e4ef349
--- /dev/null
+++ b/parser.rs
@@ -0,0 +1,1808 @@
+use std::collections::HashMap;
+use std::rc::Rc;
+use std::cell::RefCell;
+use crate::ui::action::UIAction;
+use crate::ui::types::{Suggestion, GuideOption, ScrollingSuggestion};
+
+// --- 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
+                }
+            }
+        }
+    }
+    
+    /// G

… preview truncated; 148,978 characters omitted

download full diff A

B — c_88200cfa5c4d (tommy-mor)

message

[10c9caac] Fix all workspace clippy warnings.

Wire up a missing ui_action test, allow dead code in shared integration helpers, and apply small clippy cleanups across server and types.

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

diff preview

diff --git a/server/src/dsl.rs b/server/src/dsl.rs
index a45c5b33e10d0d2ea48c7313061cfa1e6430bcfc..faa8aac6616bc6ea2b102d08ae999c01a716ef6e 100644
--- a/server/src/dsl.rs
+++ b/server/src/dsl.rs
@@ -927,9 +927,7 @@ mod tests {
     #[test]
     fn parse_vote_rejects_zero_zero_ratio() {
         let err = parse_full("{tie placeholder}\n~/a 0:0 ~/b").unwrap_err();
-        let msg = match err {
-            DslError::Parse(m) => m,
-        };
+        let DslError::Parse(msg) = err;
         assert!(
             msg.contains("0:0"),
             "expected 0:0 rejection message, got: {msg}"
diff --git a/server/src/html/garden/tests.rs b/server/src/html/garden/tests.rs
index c2036fca7752aef63d260e36cfe9649f63b5c550..0a1be1290fdc93197ca191197a473840bb4decbc 100644
--- a/server/src/html/garden/tests.rs
+++ b/server/src/html/garden/tests.rs
@@ -346,7 +346,7 @@ fn vote_compare_item_card_renders_github_import_markup() {
         "headline": "#1 Compare card",
         "sublines": ["State: open"],
     });
-    let body = format!("```slug-github-card\n{}\n```", json.to_string());
+    let body = format!("```slug-github-card\n{json}\n```");
     let html = vote_compare_item_card(
         &nav,
         &item,
diff --git a/server/src/html/ui_action.rs b/server/src/html/ui_action.rs
index 2589a2cc00bb7b18cd19ebcbb938083122d6921d..5e4131dd346a6f80bfe091a9b0cf7902721bc47f 100644
--- a/server/src/html/ui_action.rs
+++ b/server/src/html/ui_action.rs
@@ -246,6 +246,7 @@ mod tests {
         );
     }
 
+    #[test]
     fn set_new_thread_compose_expanded_true() {
         let template = serde_json::json!({
             "action": "set_new_thread_compose_expanded",
diff --git a/server/src/offline.rs b/server/src/offline.rs
index 2db6f67e22e00a24ce673d13095644dd9fa9342d..93d4d5ee55449da644f732bc0ba007ee4c2c7079 100644
--- a/server/src/offline.rs
+++ b/server/src/offline.rs
@@ -167,7 +167,7 @@ fn rankings_for_simulated(
         .iter()
         .map(|parent| {
             let scoped_content = simulated
-                .content_for_scope(&scope)
+                .content_for_scope(scope)
                 .unwrap_or_else(|| simulated.public());
             let scoped = build_children_rankings(scoped_content, parent);
             let components: Vec<RankComponent> = scoped
@@ -254,7 +254,9 @@ fn ingest_parse_error(raw: &str) -> Option<String> {
     dsl::parse_full(raw).err().map(|e| e.to_string())
 }
 
-fn load_events_from_jsonl(path: &Path) -> Result<(usize, Vec<(usize, Event)>, Vec<BadJsonLine>), std::io::Error> {
+type JsonlEventsLoad = Result<(usize, Vec<(usize, Event)>, Vec<BadJsonLine>), std::io::Error>;
+
+fn load_events_from_jsonl(path: &Path) -> JsonlEventsLoad {
     let text = std::fs::read_to_string(path)?;
     let total_lines = text.lines().count();
     let mut events = Vec::new();
diff --git a/server/src/resolvers/github.rs b/server/src/resolvers/github.rs
index 30dd4cdac96de0e3da4fa03fdf82f91bed73bfe0..3cec5e8b7249a4597c378890cc9e6125104e76c3 100644
--- a/server/src/resolvers/github.rs
+++ b/server/src/resolvers/github.rs
@@ -749,6 +749,6 @@ mod tests {
             GithubImportKind::Issue,
         );
         assert!(card.sublines.iter().any(|l| l.contains("@octo")));
-        assert_eq!(card.excerpt.as_deref(), Some("The issue body.").as_deref());
+        assert_eq!(card.excerpt.as_deref(), Some("The issue body."));
     }
 }
diff --git a/server/tests/basic.rs b/server/tests/basic.rs
index 31a35251a8abd6f4a48c1d7782b6985f621375e1..9d83e7a97e2c7494790db17c4b5b30c181705026 100644
--- a/server/tests/basic.rs
+++ b/server/tests/basic.rs
@@ -337,7 +337,7 @@ async fn event_log_handles_corrupt_lines() {
         .unwrap();
 
     // Add empty line.
-    writeln!(f, "").unwrap();
+    writeln!(f).unwrap();
 
     let (loaded, bad) = log.load_all().await.unwrap();
     assert_eq!(loaded.len(), 2);
@@ -511,9 +511,7 @@ fn dsl_parse_rejects_zero_zero_vote_ratio() {
         "~/t/a {a}\n~/t/b {b}\n{zero}\n~/t/a 0:0 ~/t/b\n",
     )
     .expect_err("0:0 vote must be rejected by the parser");
-    let msg = match err {
-        slugsocial_server::dsl::DslError::Parse(m) => m,
-    };
+    let slugsocial_server::dsl::DslError::Parse(msg) = err;
     assert!(
         msg.contains("0:0"),
         "expected message about invalid 0:0 ratio, got: {msg}"
@@ -904,7 +902,7 @@ fn posts_by_actor_indexes_and_profile_visibility() {
 fn feed_query(state: &ReducerState, cutoff: i64, limit: usize) -> (usize, Vec<String>) {
     let matching: Vec<&str> = state.ingests_ordered.iter().rev()
         .map(|id| id.as_str())
-        .take_while(|id| state.ingests_by_id.get(*id).map_or(false, |ing| ing.ts > cutoff))
+        .take_while(|id| state.ingests_by_id.get(*id).is_some_and(|ing| ing.ts > cutoff))
         .filter(|id| {
             state.ingests_by_id.get(*id).is_some_and(|ing| {
                 let scope = slugsocial_server::reducer::scope_from_room_wire(&ing.room_id);
diff --git a/server/tests/integration_health.rs b/server/tests/integration_health.rs
index 481222d8c48c44fcfb7e9ba26cf7644b5c26d5f4..351aae6b0e9738021886a076ee08fab5cf5a0001 100644
--- a/server/tests/integration_health.rs
+++ b/server/tests/integration_health.rs
@@ -7,7 +7,7 @@ async fn test_healthz() {
     let (addr, _tmp, _log, _handle) = create_test_server().await;
     let client = reqwest::Client::new();
     let response = client
-        .get(&format!("http://{}/healthz", addr))
+        .get(format!("http://{}/healthz", addr))
         .send()
         .await
         .unwrap();
diff --git a/server/tests/integration_rpc.rs b/server/tests/integration_rpc.rs
index ccd89a02594bd2a8e7047edafca04b0e54384139..ec446d94a38c8d6961d2135dd031da7ab2a39b48 100644
--- a/server/tests/integration_rpc.rs
+++ b/server/tests/integration_rpc.rs
@@ -440,7 +440,6 @@ async fn test_rank_history() {
     let bearer = test_bearer();
     let ingest = |delegate: &str, text: &str| {
         let client = client.clone();
-        let addr = addr;
         let bearer = bearer.clone();
         let text = text.to_string();
         let delegate = delegate.to_string();
diff --git a/server/tests/support/mod.rs b/server/tests/support/mod.rs
index 84dc1d68b6c1e1fdfdbd0757139c06c3daf1e9a6..4a620eaa875e7a1145f2a4e82cc4ff2be21d5345 100644
--- a/server/tests/support/mod.rs
+++ b/server/tests/support/mod.rs
@@ -1,3 +1,6 @@
+//! Shared helpers for integration tests; each test binary uses a different subset.
+#![allow(dead_code)]
+
 use sha2::{Digest, Sha256};
 use slugsocial_server::{
     event_log::EventLog,
diff --git a/types/src/paths.rs b/types/src/paths.rs
index ebc299c5e1af456c3e4b7fa45ed9fb23313e88c4..d2e799942b98dd7342764475deb17903fb60c600 100644
--- a/types/src/paths.rs
+++ b/types/src/paths.rs
@@ -411,7 +411,7 @@ mod tests {
     #[test]
     fn garden_item_url_deref_to_str() {
         let g = GardenItemUrl::from_storage_str("https://slug.social/~/x", "public");
-        let s: &str = &*g;
+        let s: &str = &g;
         assert_eq!(s, "https://slug.social/~/x");
     }
 

download full diff B

Hardlinks — judgments / attempts / prompt

prompt download

judgments

attempts

Prompt text is loaded only by the download route.