Skip to main content

classify

Function classify 

Source
pub fn classify(body: &str) -> PageType
Expand description

Classify a context segment by examining well-known prefix markers.

Classification is deterministic and performs no I/O. When the input does not match any known prefix the function defaults to PageType::ConversationTurn and logs at WARN level per FR-008.

The function emits a context.compaction.typed_page.classify span per NFR-009 so every classification is observable in traces.

Source markerAssigned PageType
Starts with [tool_output] or [tool:PageType::ToolOutput
Starts with [cross-session context], [semantic recall], [known facts], [conversation summaries]PageType::MemoryExcerpt
Starts with [Persona context], [Past experience], [Memory summary], [systemPageType::SystemContext
Everything elsePageType::ConversationTurn

ยงExamples

use zeph_context::typed_page::{classify, PageType};

assert_eq!(classify("[tool_output] exit_code: 0"), PageType::ToolOutput);
assert_eq!(classify("[cross-session context]\nsome recall"), PageType::MemoryExcerpt);
assert_eq!(classify("[Persona context]\nfact"), PageType::SystemContext);
assert_eq!(classify("Hello, world!"), PageType::ConversationTurn);