origin_types/pages.rs
1// SPDX-License-Identifier: Apache-2.0
2//! Wire types for compiled knowledge pages.
3
4use serde::{Deserialize, Serialize};
5
6/// A compiled knowledge page — structured, cross-referenced, backed by source memories.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Page {
9 pub id: String,
10 pub title: String,
11 pub summary: Option<String>,
12 pub content: String,
13 pub entity_id: Option<String>,
14 pub domain: Option<String>,
15 /// Kept for dual-write transition; prefer concept_sources join table for new reads.
16 pub source_memory_ids: Vec<String>,
17 pub version: i64,
18 pub status: String,
19 pub created_at: String,
20 pub last_compiled: String,
21 pub last_modified: String,
22 /// How many source memories were updated since last distillation.
23 pub sources_updated_count: i64,
24 /// Why this page is stale: "source_updated" | "source_conflict" | None.
25 pub stale_reason: Option<String>,
26 /// True if a human has edited this page's content directly.
27 pub user_edited: bool,
28 /// Relevance score from search (0.0-1.0). Only populated by `search_pages`;
29 /// zero for persisted/non-search contexts.
30 #[serde(default, skip_serializing_if = "is_zero_f32")]
31 pub relevance_score: f32,
32}
33
34fn is_zero_f32(v: &f32) -> bool {
35 *v == 0.0
36}