{"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[0366806e] Color rank rows by vote mass within each group, not list position.\n\nMin–max normalization keeps similar scores visually close while still\nusing the full gradient as groups grow and absolute mass dilutes.\n\nCo-authored-by: Cursor \n\nSide A — unified diff (full patch):\ndiff --git a/server/src/html/mod.rs b/server/src/html/mod.rs\nindex a58cbbee3490a08a625cb06df06848c59a615d65..4eff2e19ed4d303ff8e80c1eabd8a15b4990e643 100644\n--- a/server/src/html/mod.rs\n+++ b/server/src/html/mod.rs\n@@ -264,12 +264,19 @@ pub fn scope_theme_style(parent: &ItemId) -> String {\n )\n }\n \n-fn rank_row_style(parent: &ItemId, ordinal: usize, total: usize) -> String {\n- let t = if total <= 1 {\n- 0.0\n- } else {\n- ordinal as f64 / (total - 1) as f64\n- };\n+/// Map vote mass to gradient position using the group's score range, not raw mass or\n+/// list position. Vote mass sums to 1 across the component, so absolute values dilute\n+/// as N grows; min–max within the visible list preserves similar scores → similar colors.\n+fn score_gradient_t(score: f64, min_score: f64, max_score: f64) -> f64 {\n+ let spread = max_score - min_score;\n+ if spread < 1e-9 {\n+ return 0.5;\n+ }\n+ ((max_score - score) / spread).clamp(0.0, 1.0)\n+}\n+\n+fn rank_row_style(parent: &ItemId, score: f64, min_score: f64, max_score: f64) -> String {\n+ let t = score_gradient_t(score, min_score, max_score);\n let base_hue = scope_base_hue(parent);\n let hue = (base_hue + 118.0 * t) % 360.0;\n let lightness = 0.74 - 0.34 * t;\n@@ -295,14 +302,15 @@ fn rank_list(\n highlighted: &HashSet,\n tree: &GlobalTree,\n ) -> Markup {\n- let group_len = items.len();\n+ let min_score = items.iter().map(|r| r.score).fold(f64::INFINITY, f64::min);\n+ let max_score = items.iter().map(|r| r.score).fold(f64::NEG_INFINITY, f64::max);\n html! {\n @if !items.is_empty() {\n h3 class=\"rank-heading muted small\" { (label) }\n ol class=\"rank-list\" {\n @for (i, r) in items.iter().enumerate() {\n @let href = item_href(&r.item);\n- @let style = rank_row_style(parent, i, group_len);\n+ @let style = rank_row_style(parent, r.score, min_score, max_score);\n @let class = rank_row_class(&r.item, highlighted);\n li class=(class)\n data-rank-item=(r.item.as_str())\n@@ -517,19 +525,37 @@ pub async fn browse(State(state): State, uri: Uri) -> impl IntoRespons\n \n #[cfg(test)]\n mod tests {\n- use super::{rank_row_style, SORTER_UI_JS};\n+ use super::{rank_row_style, score_gradient_t, SORTER_UI_JS};\n use crate::path_types::ItemId;\n \n #[test]\n- fn rank_row_style_gradients_per_group_not_globally() {\n+ fn score_gradient_t_uses_group_range_not_absolute_mass() {\n+ assert!((score_gradient_t(0.12, 0.08, 0.12) - 0.0).abs() < 1e-9);\n+ assert!((score_gradient_t(0.08, 0.08, 0.12) - 1.0).abs() < 1e-9);\n+ // Raw 12% mass would map near the dark end globally; within this group it's the top.\n+ assert!(score_gradient_t(0.12, 0.08, 0.12) < score_gradient_t(0.12, 0.0, 1.0));\n+ }\n+\n+ #[test]\n+ fn score_gradient_t_similar_scores_similar_t() {\n+ let a = score_gradient_t(0.41, 0.20, 0.60);\n+ let b = score_gradient_t(0.40, 0.20, 0.60);\n+ assert!((a - b).abs() < 0.05);\n+ assert!((a - score_gradient_t(0.60, 0.20, 0.60)).abs() > 0.3);\n+ }\n+\n+ #[test]\n+ fn score_gradient_t_tied_scores_neutral() {\n+ assert!((score_gradient_t(0.25, 0.25, 0.25) - 0.5).abs() < 1e-9);\n+ }\n+\n+ #[test]\n+ fn rank_row_style_same_inputs_same_color() {\n let parent = ItemId::opaque(\"test-scope\");\n- let first_in_four = rank_row_style(&parent, 0, 4);\n- let last_in_four = rank_row_style(&parent, 3, 4);\n- let first_in_two = rank_row_style(&parent, 0, 2);\n- let last_in_two = rank_row_style(&parent, 1, 2);\n- assert_eq!(first_in_four, first_in_two);\n- assert_eq!(last_in_four, last_in_two);\n- assert_ne!(first_in_four, last_in_four);\n+ assert_eq!(\n+ rank_row_style(&parent, 0.33, 0.20, 0.60),\n+ rank_row_style(&parent, 0.33, 0.20, 0.60),\n+ );\n }\n \n #[test]\n\n\nSide B — contributor: tommy-mor\nSide B — commit message:\n[1d14ff09] Ephemeral Reddit content; log structure only (#46)\n\n* Keep Reddit content ephemeral; log structure only\n\nRemove EntityImported and EntityStore. Reddit fetches write display\ncontent directly to the projection with a fetched_at timestamp, while\nthe event log records NodeEnsured for discovered identities only.\n\nA background task evicts cached display content after 48 hours. Votes,\ntree structure, and ItemIds remain in the log and projection.\n\nCo-authored-by: tommy \n\n* Fix reddit import test assertions and Clojure syntax\n\nCo-authored-by: tommy \n\n---------\n\nCo-authored-by: Cursor Agent \n\nSide B — unified diff (full patch):\ndiff --git a/server/src/bin/storage_bench.rs b/server/src/bin/storage_bench.rs\nindex 4762d0d23bc8e2df439afe09a3235ba7f72bd486..3d988416ad36b27a7d3dc84280cfdbdcafa43e69 100644\n--- a/server/src/bin/storage_bench.rs\n+++ b/server/src/bin/storage_bench.rs\n@@ -6,8 +6,8 @@ use std::{\n };\n \n use sorter2_server::{\n- entity_store::EntityStore, event_log::EventLog, events::Event, journal::JournalClient,\n- projection_apply, projection_store::ProjectionStore,\n+ event_log::EventLog, events::Event, journal::JournalClient, projection_apply,\n+ projection_store::ProjectionStore,\n };\n \n #[tokio::main]\n@@ -18,12 +18,10 @@ async fn main() -> Result<(), Box> {\n let data_dir = opts.data_dir.to_string_lossy().into_owned();\n let event_log = Arc::new(EventLog::new(format!(\"{data_dir}/events.jsonl\")));\n let db = durable::Db::open(opts.data_dir.join(\"store\"))?;\n- let entity_store = EntityStore::from_db(&db)?;\n let projection_store = ProjectionStore::from_db(&db)?;\n \n let journal = JournalClient::spawn(\n event_log.clone(),\n- entity_store.clone(),\n projection_store.clone(),\n event_log.last_sequence().await? + 1,\n );\n@@ -46,12 +44,9 @@ async fn main() -> Result<(), Box> {\n drop(journal);\n \n let rebuild_start = Instant::now();\n- entity_store.reset()?;\n projection_store.reset()?;\n let rebuild = event_log\n- .replay(|record| {\n- projection_apply::apply_records(&projection_store, &entity_store, &[record])\n- })\n+ .replay(|record| projection_apply::apply_records(&projection_store, &[record]))\n .await?;\n let rebuild_elapsed = rebuild_start.elapsed();\n \ndiff --git a/server/src/entity_store.rs b/server/src/entity_store.rs\ndeleted file mode 100644\nindex d29f39aecca6f12cdcf263cf77c3654eb4ee6cfa..0000000000000000000000000000000000000000\n--- a/server/src/entity_store.rs\n+++ /dev/null\n@@ -1,134 +0,0 @@\n-//! Off-heap storage for full entity payloads (Reddit API JSON).\n-//!\n-//! Derived [`crate::reducer::EntityData`] is stored on the node; the raw JSON\n-//! lives here, in the shared durable [`Store`] schema.\n-\n-use std::path::Path;\n-\n-use durable::{Batch, Db, Durability};\n-use serde_json::Value;\n-\n-use crate::{\n- path_types::ItemId,\n- storage_dto::{decode_entity_payload, encode_entity_payload},\n- storage_schema::{Store, StoreFields},\n-};\n-\n-const ENTITY_SCHEMA_KEY: &str = \"schema_version\";\n-const ENTITY_SCHEMA_VERSION: u64 = 2;\n-\n-#[derive(Debug, thiserror::Error)]\n-pub enum EntityStoreError {\n- #[error(\"durable error: {0}\")]\n- Durable(#[from] durable::Error),\n- #[error(\"json error: {0}\")]\n- Json(#[from] serde_json::Error),\n- #[error(\"storage decode error: {0}\")]\n- Storage(String),\n- #[error(\"io error: {0}\")]\n- Io(#[from] std::io::Error),\n-}\n-\n-/// Disk-backed map of entity id → raw JSON payload.\n-#[derive(Clone)]\n-pub struct EntityStore {\n- db: Db,\n-}\n-\n-impl EntityStore {\n- /// Open (or create) the entity database under `dir`.\n- pub fn open(dir: &Path) -> Result {\n- std::fs::create_dir_all(dir)?;\n- let db = Db::open(dir)?;\n- Self::from_db(&db)\n- }\n-\n- /// Create an entity store backed by an already-open database.\n- pub fn from_db(db: &Db) -> Result {\n- let store = Self { db: db.clone() };\n- let version = Store::root()\n- .entity_meta()\n- .key(&ENTITY_SCHEMA_KEY.to_string())\n- .get(db)?;\n- if version != Some(ENTITY_SCHEMA_VERSION) {\n- store.reset()?;\n- }\n- Ok(store)\n- }\n-\n- /// Clear rebuildable entity payloads and reset storage schema metadata.\n- pub fn reset(&self) -> Result<(), EntityStoreError> {\n- let root = Store::root();\n- self.db.apply(\n- &[root.entities().clear(), root.entity_meta().clear()],\n- Durability::SyncWal,\n- )?;\n- self.db.run(\n- root.entity_meta()\n- .key(&ENTITY_SCHEMA_KEY.to_string())\n- .set(&ENTITY_SCHEMA_VERSION),\n- Durability::SyncWal,\n- )?;\n- Ok(())\n- }\n-\n- /// Persist a payload for `id` (overwrites any existing entry).\n- pub fn put(&self, id: &ItemId, payload: &Value) -> Result<(), EntityStoreError> {\n- self.db.run(\n- Store::root()\n- .entities()\n- .key(&id.as_str().to_string())\n- .set(&encode_entity_payload(payload)),\n- Durability::SyncWal,\n- )?;\n- Ok(())\n- }\n-\n- /// Add a payload write to the caller's batch.\n- pub fn put_in_batch(\n- &self,\n- batch: &mut Batch,\n- id: &ItemId,\n- payload: &Value,\n- ) -> Result<(), EntityStoreError> {\n- batch.write(\n- Store::root()\n- .entities()\n- .key(&id.as_str().to_string())\n- .set(&encode_entity_payload(payload)),\n- );\n- Ok(())\n- }\n-\n- /// Load a stored payload, if present.\n- pub fn get(&self, id: &ItemId) -> Result, EntityStoreError> {\n- match Store::root()\n- .entities()\n- .key(&id.as_str().to_string())\n- .get(&self.db)?\n- {\n- Some(record) => decode_entity_payload(record)\n- .map(Some)\n- .map_err(EntityStoreError::Storage),\n- None => Ok(None),\n- }\n- }\n-}\n-\n-#[cfg(test)]\n-mod tests {\n- use super::*;\n- use serde_json::json;\n-\n- #[test]\n- fn round_trip_payload() {\n- let tmp = tempfile::tempdir().unwrap();\n- let store = EntityStore::open(tmp.path()).unwrap();\n- let id = ItemId::from_url(\"https://reddit.com/r/rust\").unwrap();\n- let payload = json!({\"kind\": \"t5\", \"data\": {\"display_name\": \"rust\"}});\n-\n- store.put(&id, &payload).unwrap();\n- let loaded = store.get(&id).unwrap().unwrap();\n- assert_eq!(loaded, payload);\n- }\n-}\ndiff --git a/server/src/events.rs b/server/src/events.rs\nindex a3d88e285c645a96d33e6f0aed1b487b843aceb8..d76c3bb4277216b0d39c9422ba7a50db10a95e05 100644\n--- a/server/src/events.rs\n+++ b/server/src/events.rs\n@@ -1,5 +1,4 @@\n use serde::{Deserialize, Serialize};\n-use serde_json::Value;\n \n /// Schema version for JSONL log records. Bump when event semantics change.\n pub const CURRENT_LOG_SCHEMA: u32 = 1;\n@@ -30,7 +29,7 @@ pub type ViewRecord = LogRecord;\n /// Wall-clock timestamp carried on the log envelope for domain events.\n pub fn event_timestamp(event: &Event) -> i64 {\n match event {\n- Event::VoteRecorded { ts, .. } | Event::EntityImported { ts, .. } => *ts,\n+ Event::VoteRecorded { ts, .. } => *ts,\n Event::NodeEnsured { .. } => crate::fetch::now_ms(),\n }\n }\n@@ -57,6 +56,4 @@ pub enum Event {\n },\n /// Register a node path in the fractal tree (no external fetch).\n NodeEnsured { id: String },\n- /// Full upstream API payload for a node (domain-specific view derived at replay/render time).\n- EntityImported { id: String, ts: i64, payload: Value },\n }\ndiff --git a/server/src/journal.rs b/server/src/journal.rs\nindex 50bc89f976edb82b7b0e49e954a8eccbbe82bf87..d50023aca7c3e74068de988449b11baee32d1ecf 100644\n--- a/server/src/journal.rs\n+++ b/server/src/journal.rs\n@@ -5,7 +5,6 @@ use std::sync::Arc;\n use tokio::sync::{mpsc, oneshot};\n \n use crate::{\n- entity_store::EntityStore,\n event_log::EventLog,\n events::{event_timestamp, Event, EventRecord},\n projection_apply,\n@@ -25,7 +24,6 @@ pub struct JournalClient {\n impl JournalClient {\n pub fn spawn(\n event_log: Arc,\n- entity_store: EntityStore,\n projection_store: ProjectionStore,\n next_seq: u64,\n ) -> Self {\n@@ -33,7 +31,6 @@ impl JournalClient {\n tokio::spawn(journal_worker(\n rx,\n event_log,\n- entity_store,\n projection_store,\n next_seq,\n ));\n@@ -62,7 +59,6 @@ impl JournalClient {\n async fn journal_worker(\n mut rx: mpsc::Receiver,\n event_log: Arc,\n- entity_store: EntityStore,\n projection_store: ProjectionStore,\n mut next_seq: u64,\n ) {\n@@ -75,7 +71,6 @@ async fn journal_worker(\n let result = append_and_project_batch(\n &event_log,\n &projection_store,\n- &entity_store,\n &mut next_seq,\n &batch,\n )\n@@ -99,7 +94,6 @@ async fn journal_worker(\n async fn append_and_project_batch(\n event_log: &EventLog,\n projection_store: &ProjectionStore,\n- entity_store: &EntityStore,\n next_seq: &mut u64,\n commands: &[JournalCommand],\n ) -> Result<(), String> {\n@@ -117,7 +111,7 @@ async fn append_and_project_batch(\n .await\n .map_err(|e| e.to_string())?;\n *next_seq = seq;\n- projection_apply::apply_records(projection_store, entity_store, &records)\n+ projection_apply::apply_records(projection_store, &records)\n .map_err(|e| format!(\"projection apply failed after durable append: {e}\"))\n }\n \n@@ -132,10 +126,9 @@ mod tests {\n let log_path = tmp.path().join(\"events.jsonl\");\n let event_log = Arc::new(EventLog::new(log_path));\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n \n- let journal = JournalClient::spawn(event_log, entity_store, projection_store.clone(), 1);\n+ let journal = JournalClient::spawn(event_log, projection_store.clone(), 1);\n \n let j1 = journal.clone();\n let j2 = journal.clone();\n@@ -177,11 +170,9 @@ mod tests {\n .unwrap();\n \n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n projection_apply::apply_records(\n &projection_store,\n- &entity_store,\n &[EventRecord::new(\n 1,\n 1,\n@@ -196,7 +187,6 @@ mod tests {\n \n let journal = JournalClient::spawn(\n event_log.clone(),\n- entity_store,\n projection_store.clone(),\n next_seq,\n );\n@@ -219,10 +209,9 @@ mod tests {\n let log_path = tmp.path().join(\"events.jsonl\");\n let event_log = Arc::new(EventLog::new(log_path));\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n let journal =\n- JournalClient::spawn(event_log.clone(), entity_store, projection_store.clone(), 1);\n+ JournalClient::spawn(event_log.clone(), projection_store.clone(), 1);\n \n journal\n .append_many(vec![\ndiff --git a/server/src/lib.rs b/server/src/lib.rs\nindex 5c02c8e704e4664453bad75d819df8a067668176..3dfc7c8acb8ed61bb73ade63e72768e402042cc5 100644\n--- a/server/src/lib.rs\n+++ b/server/src/lib.rs\n@@ -1,5 +1,4 @@\n pub mod api;\n-pub mod entity_store;\n pub mod event_log;\n pub mod events;\n pub mod fetch;\ndiff --git a/server/src/projection_apply.rs b/server/src/projection_apply.rs\nindex 5644557a41b3e9497c7421b444155ae629fa79f1..9c8990a8af927f35d3344c8d0872a516aba56b86 100644\n--- a/server/src/projection_apply.rs\n+++ b/server/src/projection_apply.rs\n@@ -1,22 +1,20 @@\n //! Apply event-log records to the durable projection as precise point updates.\n //!\n //! Each batch of records lowers to reified durable writes (edge merges, child\n-//! links, voted-pair flags, recent-vote pushes, entity payloads) plus a cursor\n-//! advance, all committed in one atomic `DisableWal` batch. The cursor moving in\n-//! the same batch as the (non-idempotent) edge merges guarantees exactly-once\n-//! application across replay.\n+//! links, voted-pair flags, recent-vote pushes) plus a cursor advance, all\n+//! committed in one atomic `DisableWal` batch. The cursor moving in the same\n+//! batch as the (non-idempotent) edge merges guarantees exactly-once application\n+//! across replay.\n \n use std::collections::BTreeSet;\n \n use crate::{\n- entity_store::EntityStore,\n event_log::EventLogError,\n events::{Event, EventRecord},\n path_types::ItemId,\n projection_store::ProjectionStore,\n- reddit::entity_view_from_payload,\n reducer::VoteData,\n- storage_schema::{ensure_path_writes, entity_view_writes, vote_writes},\n+ storage_schema::{ensure_path_writes, vote_writes},\n };\n \n fn parse_event_id(id: &str) -> Result {\n@@ -38,7 +36,6 @@ fn parent_from_event_scope(scope: &str) -> ItemId {\n \n pub fn apply_records(\n projection_store: &ProjectionStore,\n- entity_store: &EntityStore,\n records: &[EventRecord],\n ) -> Result<(), EventLogError> {\n if records.is_empty() {\n@@ -79,14 +76,6 @@ pub fn apply_records(\n let parsed = parse_event_id(id)?;\n ensure_path_writes(&mut batch, &parsed);\n }\n- Event::EntityImported { id, payload, .. } => {\n- let parsed = parse_event_id(id)?;\n- let view = entity_view_from_payload(&parsed, payload);\n- entity_view_writes(&mut batch, &parsed, view.as_ref());\n- entity_store\n- .put_in_batch(&mut batch, &parsed, payload)\n- .map_err(|e| EventLogError::Apply(e.to_string()))?;\n- }\n }\n last_seq = record.seq;\n }\ndiff --git a/server/src/projection_store.rs b/server/src/projection_store.rs\nindex 30ee478f953e80d7322bdbfa521ae559ff08fa51..8576d671f351004426207894ac35594ddb0f70cf 100644\n--- a/server/src/projection_store.rs\n+++ b/server/src/projection_store.rs\n@@ -9,13 +9,16 @@ use durable::{Db, Durability, Write};\n \n use crate::{\n path_types::ItemId,\n- reducer::{GlobalTree, NodeState},\n- storage_schema::{load_node_state, node, NodeSchemaFields, Store, StoreFields},\n+ reducer::{EntityData, GlobalTree, NodeState},\n+ storage_schema::{\n+ entity_content_clear_writes, entity_content_writes, load_node_state, node, NodeSchemaFields,\n+ Store, StoreFields,\n+ },\n };\n \n const PROJECTION_CURSOR_KEY: &str = \"cursor\";\n const PROJECTION_SCHEMA_KEY: &str = \"schema_version\";\n-const PROJECTION_SCHEMA_VERSION: u64 = 2;\n+const PROJECTION_SCHEMA_VERSION: u64 = 3;\n \n #[derive(Debug, thiserror::Error)]\n pub enum ProjectionStoreError {\n@@ -148,6 +151,45 @@ impl ProjectionStore {\n )?;\n Ok(())\n }\n+\n+ /// Cache Reddit display content outside the event log (must be evicted per policy).\n+ pub fn put_ephemeral_content(\n+ &self,\n+ id: &ItemId,\n+ view: &EntityData,\n+ fetched_at: i64,\n+ ) -> Result<(), ProjectionStoreError> {\n+ let mut batch = self.db.batch();\n+ entity_content_writes(&mut batch, id, view, fetched_at);\n+ batch\n+ .commit_with(Durability::DisableWal)\n+ .map_err(ProjectionStoreError::from)?;\n+ Ok(())\n+ }\n+\n+ /// Drop cached display content older than `cutoff_ms` (votes and tree structure remain).\n+ pub fn evict_content_older_than(&self, cutoff_ms: i64) -> Result {\n+ let keys = Store::root().nodes().keys(&self.db)?;\n+ let mut batch = self.db.batch();\n+ let mut evicted = 0usize;\n+ for key in keys {\n+ let id = parse_node_key(&key)?;\n+ let np = node(&id);\n+ let Some(fetched_at) = np.fetched_at().get(&self.db)? else {\n+ continue;\n+ };\n+ if fetched_at > 0 && fetched_at < cutoff_ms {\n+ entity_content_clear_writes(&mut batch, &id);\n+ evicted += 1;\n+ }\n+ }\n+ if evicted > 0 {\n+ batch\n+ .commit_with(Durability::DisableWal)\n+ .map_err(ProjectionStoreError::from)?;\n+ }\n+ Ok(evicted)\n+ }\n }\n \n fn parse_node_key(key: &str) -> Result {\n@@ -162,7 +204,7 @@ fn parse_node_key(key: &str) -> Result {\n #[cfg(test)]\n mod tests {\n use super::*;\n- use crate::{entity_store::EntityStore, events::Event, projection_apply};\n+ use crate::{events::Event, projection_apply, reducer::EntityData};\n \n fn record(seq: u64, event: Event) -> crate::events::EventRecord {\n crate::events::EventRecord::new(seq, crate::events::event_timestamp(&event), event)\n@@ -172,7 +214,6 @@ mod tests {\n fn applies_and_loads_reducer_nodes() {\n let tmp = tempfile::tempdir().unwrap();\n let db = Db::open(tmp.path()).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let store = ProjectionStore::from_db(&db).unwrap();\n \n let event = Event::VoteRecorded {\n@@ -183,7 +224,7 @@ mod tests {\n ratio_right: 1,\n scope: String::new(),\n };\n- projection_apply::apply_records(&store, &entity_store, &[record(1, event)]).unwrap();\n+ projection_apply::apply_records(&store, &[record(1, event)]).unwrap();\n assert_eq!(store.last_applied_event_count().unwrap(), 1);\n \n let loaded = store.load_tree().unwrap();\n@@ -196,7 +237,6 @@ mod tests {\n fn hydrates_scope_with_child_nodes() {\n let tmp = tempfile::tempdir().unwrap();\n let db = Db::open(tmp.path()).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let store = ProjectionStore::from_db(&db).unwrap();\n \n let event = Event::VoteRecorded {\n@@ -207,11 +247,36 @@ mod tests {\n ratio_right: 1,\n scope: String::new(),\n };\n- projection_apply::apply_records(&store, &entity_store, &[record(1, event)]).unwrap();\n+ projection_apply::apply_records(&store, &[record(1, event)]).unwrap();\n \n let scoped = store.scope_tree(&ItemId::root()).unwrap();\n let root = scoped.get(&ItemId::root()).unwrap();\n assert_eq!(root.children.len(), 2);\n assert!(scoped.get(&ItemId::opaque(\"alpha\")).is_some());\n }\n+\n+ #[test]\n+ fn evicts_stale_ephemeral_content() {\n+ let tmp = tempfile::tempdir().unwrap();\n+ let db = Db::open(tmp.path()).unwrap();\n+ let store = ProjectionStore::from_db(&db).unwrap();\n+ let id = ItemId::from_url(\"https://reddit.com/r/rust\").unwrap();\n+ store\n+ .put_ephemeral_content(\n+ &id,\n+ &EntityData {\n+ title: \"Rust\".into(),\n+ author: None,\n+ body_html: None,\n+ thumb_url: None,\n+ image_url: None,\n+ link_url: None,\n+ },\n+ 1_000,\n+ )\n+ .unwrap();\n+ assert!(store.load_node(&id).unwrap().unwrap().data.is_some());\n+ assert_eq!(store.evict_content_older_than(2_000).unwrap(), 1);\n+ assert!(store.load_node(&id).unwrap().unwrap().data.is_none());\n+ }\n }\ndiff --git a/server/src/reddit.rs b/server/src/reddit.rs\nindex 20b7f9e3f8be39268a1767d09f5cf81eaa6ae0df..a874814f8927192ee62cab2d0db1efd27dcd57b7 100644\n--- a/server/src/reddit.rs\n+++ b/server/src/reddit.rs\n@@ -9,10 +9,13 @@ use serde_json::Value;\n use tokio::sync::{mpsc, oneshot};\n \n use crate::{\n- entity_store::EntityStore, events::Event, fetch::now_ms, journal::JournalClient,\n- path_types::ItemId, reducer::GlobalTree,\n+ events::Event, fetch::now_ms, journal::JournalClient,\n+ path_types::ItemId, projection_store::ProjectionStore,\n };\n \n+/// Reddit display content must not be retained longer than this (API policy).\n+pub const REDDIT_CONTENT_TTL: std::time::Duration = std::time::Duration::from_secs(48 * 3600);\n+\n #[derive(Debug, Clone, PartialEq, Eq)]\n pub enum FetchJobResult {\n /// Number of entities written (1 for self, N for children).\n@@ -70,7 +73,11 @@ struct OAuthToken {\n }\n \n impl RedditBroker {\n- pub fn spawn(journal: JournalClient, config: RedditApiConfig) -> Self {\n+ pub fn spawn(\n+ journal: JournalClient,\n+ projection_store: ProjectionStore,\n+ config: RedditApiConfig,\n+ ) -> Self {\n let (tx, rx) = mpsc::channel(100);\n \n let mut headers = header::HeaderMap::new();\n@@ -93,7 +100,7 @@ impl RedditBroker {\n \"reddit worker started\"\n );\n \n- tokio::spawn(reddit_worker(rx, journal, client, config));\n+ tokio::spawn(reddit_worker(rx, journal, projection_store, client, config));\n \n Self { tx }\n }\n@@ -189,27 +196,50 @@ pub fn entity_view_from_payload(\n None\n }\n \n-pub fn apply_entity_import(\n- tree: &mut GlobalTree,\n- store: &EntityStore,\n- id: &ItemId,\n- payload: Value,\n-) -> Result<(), String> {\n- let view = entity_view_from_payload(id, &payload);\n- store.put(id, &payload).map_err(|e| e.to_string())?;\n- tree.apply_entity(id, view);\n- Ok(())\n-}\n-\n fn notify(done: Option>, result: FetchJobResult) {\n if let Some(tx) = done {\n let _ = tx.send(result);\n }\n }\n \n+async fn import_fetched_payload(\n+ kind: FetchKind,\n+ fetch_id: &ItemId,\n+ payload: Value,\n+ projection_store: &ProjectionStore,\n+ journal: &JournalClient,\n+) -> Result {\n+ let fetched_at = now_ms();\n+ let imports: Vec<(ItemId, Value)> = match kind {\n+ FetchKind::SelfEntity => vec![(fetch_id.clone(), payload)],\n+ FetchKind::Children => parse_children(fetch_id, &payload),\n+ };\n+\n+ for (id, child_payload) in &imports {\n+ if let Some(view) = entity_view_from_payload(id, child_payload) {\n+ projection_store\n+ .put_ephemeral_content(id, &view, fetched_at)\n+ .map_err(|e| e.to_string())?;\n+ }\n+ }\n+\n+ let events: Vec = imports\n+ .iter()\n+ .map(|(id, _)| Event::NodeEnsured {\n+ id: id.as_str().to_string(),\n+ })\n+ .collect();\n+ let written = events.len();\n+ if !events.is_empty() {\n+ journal.append_many(events).await?;\n+ }\n+ Ok(written)\n+}\n+\n async fn reddit_worker(\n mut rx: mpsc::Receiver,\n journal: JournalClient,\n+ projection_store: ProjectionStore,\n client: Client,\n config: RedditApiConfig,\n ) {\n@@ -276,33 +306,20 @@ async fn reddit_worker(\n \n match outcome {\n Ok(FetchOutcome::Payload(payload)) => {\n- let imports: Vec<(ItemId, Value)> = match kind {\n- FetchKind::SelfEntity => vec![(fetch_id.clone(), payload)],\n- FetchKind::Children => parse_children(&fetch_id, &payload),\n- };\n tracing::debug!(\n item = %fetch_id,\n ?kind,\n- count = imports.len(),\n- \"reddit fetch got payload, importing\"\n+ \"reddit fetch got payload, caching ephemerally\"\n );\n \n- let events: Vec = imports\n- .into_iter()\n- .map(|(child_id, child_payload)| Event::EntityImported {\n- id: child_id.as_str().to_string(),\n- ts: now_ms(),\n- payload: child_payload,\n- })\n- .collect();\n- let written = events.len();\n-\n- match journal.append_many(events).await {\n+ match import_fetched_payload(kind, &fetch_id, payload, &projection_store, &journal)\n+ .await\n+ {\n Err(e) => {\n- tracing::warn!(item = %fetch_id, err = %e, \"reddit import journal failed\");\n+ tracing::warn!(item = %fetch_id, err = %e, \"reddit import failed\");\n notify(done, FetchJobResult::Failed(e));\n }\n- Ok(()) => {\n+ Ok(written) => {\n recently_fetched.insert(key.clone(), Instant::now());\n current_delay = Duration::from_millis(600);\n tracing::info!(item = %fetch_id, ?kind, written, \"reddit import complete\");\ndiff --git a/server/src/reducer.rs b/server/src/reducer.rs\nindex 1352a8f0771add3d868a1b30109b087a2a6dba6f..0c75c85150bb9e5f578bbadf58b3e43f8a80be4b 100644\n--- a/server/src/reducer.rs\n+++ b/server/src/reducer.rs\n@@ -136,8 +136,7 @@ pub struct EntityData {\n #[derive(Debug, Clone, Default, Serialize, Deserialize)]\n pub struct NodeState {\n pub id: ItemId,\n- /// Domain-specific view derived from imported payload (e.g. Reddit title/author).\n- /// Raw JSON lives in [`crate::entity_store::EntityStore`].\n+ /// Ephemeral display view (Reddit title/author/etc.; not event-logged).\n pub data: Option,\n pub children: HashSet,\n pub local_ranking: GroupState,\ndiff --git a/server/src/state.rs b/server/src/state.rs\nindex e44849eec46123072b238afd40a1fdd51ce19bd9..247b9047a57956f76c4b6bef691662101e62a8f9 100644\n--- a/server/src/state.rs\n+++ b/server/src/state.rs\n@@ -1,14 +1,14 @@\n use std::{error::Error, sync::Arc};\n \n use crate::{\n- entity_store::EntityStore,\n event_log::EventLog,\n events::Event,\n+ fetch::now_ms,\n journal::JournalClient,\n path_types::ItemId,\n projection_apply,\n projection_store::ProjectionStore,\n- reddit::{RedditApiConfig, RedditBroker},\n+ reddit::{RedditApiConfig, RedditBroker, REDDIT_CONTENT_TTL},\n reducer::{GlobalTree, VoteData},\n view_log::ViewLog,\n views::ViewStore,\n@@ -45,7 +45,6 @@ pub fn normalize_scope(raw: &str) -> String {\n \n async fn catch_up_projection(\n event_log: &EventLog,\n- entity_store: &EntityStore,\n projection_store: &ProjectionStore,\n ) -> Result<(), crate::event_log::EventLogError> {\n let after_seq = projection_store\n@@ -54,7 +53,7 @@ async fn catch_up_projection(\n \n let stats = event_log\n .replay_from(after_seq, |record| {\n- projection_apply::apply_records(projection_store, entity_store, &[record])\n+ projection_apply::apply_records(projection_store, &[record])\n })\n .await?;\n if after_seq > stats.last_seq {\n@@ -67,22 +66,34 @@ async fn catch_up_projection(\n Ok(())\n }\n \n+fn spawn_content_evictor(projection_store: ProjectionStore) {\n+ tokio::spawn(async move {\n+ let mut interval = tokio::time::interval(std::time::Duration::from_secs(15 * 60));\n+ interval.tick().await;\n+ loop {\n+ interval.tick().await;\n+ let cutoff = now_ms() - REDDIT_CONTENT_TTL.as_millis() as i64;\n+ match projection_store.evict_content_older_than(cutoff) {\n+ Ok(0) => {}\n+ Ok(n) => tracing::info!(evicted = n, \"reddit display content TTL eviction\"),\n+ Err(e) => tracing::warn!(err = %e, \"reddit content TTL eviction failed\"),\n+ }\n+ }\n+ });\n+}\n+\n pub async fn rebuild_projection(\n cfg: &AppConfig,\n ) -> Result> {\n let event_log = EventLog::new(cfg.event_log_path.clone());\n let store_path = format!(\"{}/store\", cfg.data_dir);\n let db = durable::Db::open(std::path::Path::new(&store_path))?;\n- let entity_store = EntityStore::from_db(&db)?;\n let projection_store = ProjectionStore::from_db(&db)?;\n \n- entity_store.reset()?;\n projection_store.reset()?;\n \n let stats = event_log\n- .replay(|record| {\n- projection_apply::apply_records(&projection_store, &entity_store, &[record])\n- })\n+ .replay(|record| projection_apply::apply_records(&projection_store, &[record]))\n .await?;\n let cursor = projection_store.last_applied_event_count()?;\n if cursor != stats.last_seq {\n@@ -132,7 +143,6 @@ pub struct AppState {\n pub cfg: Arc,\n pub event_log: Arc,\n pub view_log: Arc,\n- pub entity_store: EntityStore,\n pub projection_store: ProjectionStore,\n pub views: ViewStore,\n journal: JournalClient,\n@@ -145,7 +155,6 @@ impl AppState {\n let view_log = Arc::new(ViewLog::new(cfg.views_log_path.clone()));\n let store_path = format!(\"{}/store\", cfg.data_dir);\n let db = durable::Db::open(std::path::Path::new(&store_path))?;\n- let entity_store = EntityStore::from_db(&db)?;\n let projection_store = ProjectionStore::from_db(&db)?;\n let views = ViewStore::from_db(&db)?;\n \n@@ -157,22 +166,25 @@ impl AppState {\n }\n views.spawn_worker(view_log.clone());\n \n- catch_up_projection(&event_log, &entity_store, &projection_store).await?;\n+ catch_up_projection(&event_log, &projection_store).await?;\n let next_seq = event_log.last_sequence().await? + 1;\n \n let journal = JournalClient::spawn(\n event_log.clone(),\n- entity_store.clone(),\n projection_store.clone(),\n next_seq,\n );\n- let reddit = RedditBroker::spawn(journal.clone(), RedditApiConfig::from_env());\n+ let reddit = RedditBroker::spawn(\n+ journal.clone(),\n+ projection_store.clone(),\n+ RedditApiConfig::from_env(),\n+ );\n+ spawn_content_evictor(projection_store.clone());\n \n Ok(Self {\n cfg: Arc::new(cfg),\n event_log,\n view_log,\n- entity_store,\n projection_store,\n views,\n journal,\n@@ -248,54 +260,72 @@ impl AppState {\n mod tests {\n use super::{normalize_scope, parse_item_param, AppConfig, AppState};\n use crate::{\n- entity_store::EntityStore, event_log::EventLog, events::Event, path_types::ItemId,\n- projection_apply, projection_store::ProjectionStore,\n+ event_log::EventLog, events::Event, path_types::ItemId, projection_apply,\n+ projection_store::ProjectionStore, reducer::EntityData,\n };\n- use serde_json::json;\n \n fn event_record(seq: u64, event: Event) -> crate::events::EventRecord {\n crate::events::EventRecord::new(seq, crate::events::event_timestamp(&event), event)\n }\n \n #[tokio::test]\n- async fn replay_entity_imported_restores_view() {\n+ async fn rebuild_projection_drops_ephemeral_content() {\n let tmp = tempfile::tempdir().unwrap();\n- let log_path = tmp.path().join(\"events.jsonl\");\n- let log = EventLog::new(log_path.to_string_lossy().into_owned());\n- let payload = json!({\"kind\":\"t5\",\"data\":{\"title\":\"Rust\",\"display_name\":\"rust\"}});\n- let event = Event::EntityImported {\n- id: \"https://reddit.com/r/rust\".into(),\n- ts: 1,\n- payload: payload.clone(),\n- };\n- log.append(&event_record(1, event)).await.unwrap();\n+ let data_dir = tmp.path().to_string_lossy().into_owned();\n+ let log = EventLog::new(format!(\"{data_dir}/events.jsonl\"));\n+ log.append(&event_record(\n+ 1,\n+ Event::NodeEnsured {\n+ id: \"https://reddit.com/r/rust\".into(),\n+ },\n+ ))\n+ .await\n+ .unwrap();\n \n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n- super::catch_up_projection(&log, &entity_store, &projection_store)\n+ super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap();\n- let tree = projection_store\n- .scope_tree(&ItemId::parse(\"https://reddit.com/r/rust\").unwrap())\n- .unwrap();\n- let node = tree\n- .get(&ItemId::parse(\"https://reddit.com/r/rust\").unwrap())\n- .unwrap();\n- assert_eq!(node.data.as_ref().unwrap().title, \"Rust\");\n- let stored = entity_store\n- .get(&ItemId::parse(\"https://reddit.com/r/rust\").unwrap())\n- .unwrap()\n+ let id = ItemId::parse(\"https://reddit.com/r/rust\").unwrap();\n+ projection_store\n+ .put_ephemeral_content(\n+ &id,\n+ &EntityData {\n+ title: \"Rust\".into(),\n+ author: None,\n+ body_html: None,\n+ thumb_url: None,\n+ image_url: None,\n+ link_url: None,\n+ },\n+ 1,\n+ )\n .unwrap();\n- assert_eq!(stored[\"data\"][\"display_name\"], \"rust\");\n+ assert!(projection_store.load_node(&id).unwrap().unwrap().data.is_some());\n+ drop(projection_store);\n+ drop(db);\n+\n+ super::rebuild_projection(&AppConfig {\n+ data_dir: data_dir.clone(),\n+ event_log_path: format!(\"{data_dir}/events.jsonl\"),\n+ views_log_path: format!(\"{data_dir}/views.jsonl\"),\n+ port: 0,\n+ })\n+ .await\n+ .unwrap();\n+\n+ let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n+ let projection_store = ProjectionStore::from_db(&db).unwrap();\n+ let node = projection_store.load_node(&id).unwrap().unwrap();\n+ assert!(node.data.is_none());\n }\n \n #[tokio::test]\n- async fn rebuild_projection_restores_nodes_payloads_and_cursor_from_jsonl() {\n+ async fn rebuild_projection_restores_structure_and_cursor_from_jsonl() {\n let tmp = tempfile::tempdir().unwrap();\n let data_dir = tmp.path().to_string_lossy().into_owned();\n let log = EventLog::new(format!(\"{data_dir}/events.jsonl\"));\n- let payload = json!({\"kind\":\"t5\",\"data\":{\"title\":\"Rust\",\"display_name\":\"rust\"}});\n log.append_batch(&[\n event_record(\n 1,\n@@ -305,16 +335,8 @@ mod tests {\n ),\n event_record(\n 2,\n- Event::EntityImported {\n- id: \"https://reddit.com/r/rust\".into(),\n- ts: 2,\n- payload: payload.clone(),\n- },\n- ),\n- event_record(\n- 3,\n Event::VoteRecorded {\n- ts: 3,\n+ ts: 2,\n a: \"alpha\".into(),\n b: \"beta\".into(),\n ratio_left: 2,\n@@ -328,11 +350,9 @@ mod tests {\n \n {\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n projection_apply::apply_records(\n &projection_store,\n- &entity_store,\n &[event_record(\n 1,\n Event::NodeEnsured {\n@@ -352,13 +372,12 @@ mod tests {\n })\n .await\n .unwrap();\n- assert_eq!(stats.applied, 3);\n- assert_eq!(stats.last_seq, 3);\n+ assert_eq!(stats.applied, 2);\n+ assert_eq!(stats.last_seq, 2);\n \n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n- assert_eq!(projection_store.last_applied_event_count().unwrap(), 3);\n+ assert_eq!(projection_store.last_applied_event_count().unwrap(), 2);\n let tree = projection_store.scope_tree(&ItemId::root()).unwrap();\n let root = tree.get(&ItemId::root()).unwrap();\n assert!(root.children.contains(&ItemId::parse(\"alpha\").unwrap()));\n@@ -366,11 +385,6 @@ mod tests {\n .load_node(&ItemId::parse(\"https://reddit.com/r/stale\").unwrap())\n .unwrap()\n .is_none());\n- let stored = entity_store\n- .get(&ItemId::parse(\"https://reddit.com/r/rust\").unwrap())\n- .unwrap()\n- .unwrap();\n- assert_eq!(stored[\"data\"][\"display_name\"], \"rust\");\n }\n \n #[tokio::test]\n@@ -389,12 +403,9 @@ mod tests {\n \n {\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n- // Advance the projection cursor to 2 while the log tail is only 1.\n projection_apply::apply_records(\n &projection_store,\n- &entity_store,\n &[event_record(\n 2,\n Event::NodeEnsured {\n@@ -403,7 +414,7 @@ mod tests {\n )],\n )\n .unwrap();\n- let err = super::catch_up_projection(&log, &entity_store, &projection_store)\n+ let err = super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap_err();\n assert!(err\n@@ -432,10 +443,9 @@ mod tests {\n .unwrap();\n \n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n \n- super::catch_up_projection(&log, &entity_store, &projection_store)\n+ super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap();\n assert_eq!(projection_store.last_applied_event_count().unwrap(), 1);\n@@ -444,7 +454,7 @@ mod tests {\n let first_edge_total: f64 = first_root.local_ranking.edges.values().sum();\n assert_eq!(first_edge_total, 3.0);\n \n- super::catch_up_projection(&log, &entity_store, &projection_store)\n+ super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap();\n assert_eq!(projection_store.last_applied_event_count().unwrap(), 1);\n@@ -556,9 +566,8 @@ mod tests {\n .unwrap();\n {\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n- super::catch_up_projection(&log, &entity_store, &projection_store)\n+ super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap();\n }\n@@ -605,9 +614,8 @@ mod tests {\n .unwrap();\n {\n let db = durable::Db::open(tmp.path().join(\"store\")).unwrap();\n- let entity_store = EntityStore::from_db(&db).unwrap();\n let projection_store = ProjectionStore::from_db(&db).unwrap();\n- super::catch_up_projection(&log, &entity_store, &projection_store)\n+ super::catch_up_projection(&log, &projection_store)\n .await\n .unwrap();\n }\ndiff --git a/server/src/storage_dto.rs b/server/src/storage_dto.rs\nindex de5ed995797ae306d3a71394a4d9d245ffd5771d..9dfb13c53efe4389277625a6ab3bfc18f566a453 100644\n--- a/server/src/storage_dto.rs\n+++ b/server/src/storage_dto.rs\n@@ -3,17 +3,15 @@\n //! Node structure (children, edges, voted pairs, recent votes) is no longer a\n //! single blob — it lives as point-addressable durable collections (see\n //! [`crate::storage_schema`]). This module only defines the small leaf values:\n-//! the derived entity view, raw entity payloads, and individual votes.\n+//! ephemeral entity views and individual votes.\n \n use serde::{Deserialize, Serialize};\n-use serde_json::Value;\n \n use crate::{\n path_types::ItemId,\n reducer::{EntityData, VoteData},\n };\n \n-pub const ENTITY_RECORD_VERSION: u32 = 1;\n pub const VOTE_RECORD_VERSION: u32 = 1;\n pub const ENTITY_DATA_VERSION: u32 = 1;\n \n@@ -29,14 +27,7 @@ impl Versioned {\n }\n }\n \n-pub type StoredEntityRecord = Versioned;\n-\n-#[derive(Debug, Clone, Serialize, Deserialize)]\n-pub struct StoredEntityV1 {\n- pub json: Value,\n-}\n-\n-/// Derived entity view stored at a node's `data` leaf.\n+/// Derived entity view stored at a node's `data` leaf (ephemeral; not logged).\n #[derive(Debug, Clone, Serialize, Deserialize)]\n pub struct StoredEntityDataV1 {\n pub version: u32,\n@@ -63,25 +54,6 @@ pub struct StoredVoteV1 {\n pub thread_tag: String,\n }\n \n-pub fn encode_entity_payload(payload: &Value) -> StoredEntityRecord {\n- Versioned::new(\n- ENTITY_RECORD_VERSION,\n- StoredEntityV1 {\n- json: payload.clone(),\n- },\n- )\n-}\n-\n-pub fn decode_entity_payload(record: StoredEntityRecord) -> Result {\n- if record.version != ENTITY_RECORD_VERSION {\n- return Err(format!(\n- \"unsupported entity record version: {}\",\n- record.version\n- ));\n- }\n- Ok(record.payload.json)\n-}\n-\n pub fn encode_entity_data(data: &EntityData) -> StoredEntityDataV1 {\n StoredEntityDataV1 {\n version: ENTITY_DATA_VERSION,\ndiff --git a/server/src/storage_schema.rs b/server/src/storage_schema.rs\nindex 76bf7bc74a2c5ef4f78678a333b7661778f5b835..bd26e665e084b95b10fdfff091c31e8dc84d07b8 100644\n--- a/server/src/storage_schema.rs\n+++ b/server/src/storage_schema.rs\n@@ -15,7 +15,7 @@ use crate::{\n reducer::{EntityData, GroupState, NodeState, VoteData},\n storage_dto::{\n decode_entity_data, decode_vote, encode_entity_data, encode_vote, parse_stored_id,\n- StoredEntityDataV1, StoredEntityRecord, StoredVoteV1,\n+ StoredEntityDataV1, StoredVoteV1,\n },\n };\n \n@@ -40,17 +40,17 @@ pub struct NodeSchema {\n pub voted_pairs: Map>,\n /// Recent votes, newest at the front (capped on write).\n pub recent_votes: Deque>,\n+ /// When ephemeral Reddit display content was last fetched (ms); absent after eviction.\n+ pub fetched_at: Leaf,\n }\n \n-/// The single database root: nodes, raw payloads, view counts, and per-concern\n-/// metadata maps (cursors and schema versions).\n+/// The single database root: nodes, view counts, and per-concern metadata maps\n+/// (cursors and schema versions).\n #[derive(Durable)]\n #[allow(dead_code)]\n pub struct Store {\n pub nodes: Map,\n pub proj_meta: Map>,\n- pub entities: Map>,\n- pub entity_meta: Map>,\n pub view_counts: Map>,\n pub view_meta: Map>,\n }\n@@ -264,12 +264,17 @@ pub fn vote_writes(\n Ok(())\n }\n \n-/// Reified writes for an imported entity view (node data + path wiring).\n-pub fn entity_view_writes(batch: &mut Batch, id: &ItemId, view: Option<&EntityData>) {\n+/// Reified writes for ephemeral Reddit display content (not event-logged).\n+pub fn entity_content_writes(batch: &mut Batch, id: &ItemId, view: &EntityData, fetched_at: i64) {\n ensure_path_writes(batch, id);\n- if let Some(view) = view {\n- batch.write(node(id).data().set(&encode_entity_data(view)));\n- }\n+ batch.write(node(id).data().set(&encode_entity_data(view)));\n+ batch.write(node(id).fetched_at().set(&fetched_at));\n+}\n+\n+/// Clear cached display content for one node (structure/votes are untouched).\n+pub fn entity_content_clear_writes(batch: &mut Batch, id: &ItemId) {\n+ batch.write(node(id).data().delete());\n+ batch.write(node(id).fetched_at().delete());\n }\n \n #[cfg(test)]\ndiff --git a/test/reddit_import.clj b/test/reddit_import.clj\nindex b476488526252c13fd73bdda76e5201678e4a714..6d8c5bca7ebad0b5abfddecd4ea48cc09d738ebe 100644\n--- a/test/reddit_import.clj\n+++ b/test/reddit_import.clj\n@@ -59,9 +59,10 @@\n \"curl\" \"-sf\" browse-url))\n log (slurp (io/file log-path))]\n (is (str/includes? after \"The Rust Programming Language\"))\n- (is (str/includes? log \"\\\"type\\\":\\\"entity_imported\\\"\"))\n- (is (str/includes? log \"\\\"subscribers\\\":350000\"))\n- (is (str/includes? log \"\\\"display_name\\\":\\\"rust\\\"\")))\n+ (is (str/includes? log \"\\\"type\\\":\\\"node_ensured\\\"\"))\n+ (is (not (str/includes? log \"\\\"subscribers\\\"\")))\n+ (is (not (str/includes? log \"\\\"display_name\\\"\")))\n+ (is (not (str/includes? log \"entity_imported\"))))\n (let [children-sse (curl-fetch-ui-sse app-base \"reddit.com/r/rust\" \"children\")]\n (is (zero? (:exit children-sse)) \"POST /ui fetch_entity (children) SSE succeeds\")\n (is (str/includes? (:out children-sse) \"Idiomorph.morph\"))\n@@ -71,10 +72,12 @@\n log2 (slurp (io/file log-path))]\n (is (str/includes? after-children \"Announcing Rust 1.99\"))\n (is (str/includes? after-children \"Unranked\"))\n- (is (str/includes? log2 \"announcing_rust_199\")))))\n+ (is (str/includes? log2 \"\\\"type\\\":\\\"node_ensured\\\"\"))\n+ (is (str/includes? log2 \"/comments/\"))\n+ (is (not (str/includes? log2 \"\\\"selftext\\\"\"))))))\n \n (deftest reddit-fetch-via-mock-api\n- (testing \"Fetch more queues import; event log stores full payload; page shows title\"\n+ (testing \"Fetch caches display content ephemerally; log records structure only\"\n (let [root (repo-root)\n fixtures (mock-reddit/fixtures-dir root)\n data-dir (.getAbsolutePath\n","role":"user"}],"model":"openai/gpt-chat-latest"}