Skip to main content

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    #[serde(default, alias = "domain")]
15    pub space: Option<String>,
16    /// Kept for dual-write transition; prefer concept_sources join table for new reads.
17    pub source_memory_ids: Vec<String>,
18    pub version: i64,
19    pub status: String,
20    pub created_at: String,
21    pub last_compiled: String,
22    pub last_modified: String,
23    /// How many source memories were updated since last distillation.
24    pub sources_updated_count: i64,
25    /// Why this page is stale: "source_updated" | "source_conflict" | None.
26    pub stale_reason: Option<String>,
27    /// True if a human has edited this page's content directly.
28    pub user_edited: bool,
29    /// Relevance score from search (0.0-1.0). Only populated by `search_pages`;
30    /// zero for persisted/non-search contexts.
31    #[serde(default, skip_serializing_if = "is_zero_f32")]
32    pub relevance_score: f32,
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub last_edited_by: Option<String>,
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub last_edited_at: Option<i64>,
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub last_delta_summary: Option<String>,
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub changelog: Option<String>,
41}
42
43fn is_zero_f32(v: &f32) -> bool {
44    *v == 0.0
45}