deepstrike_core/mm/
mod.rs1use crate::context::pressure::PressureAction;
9use serde::{Deserialize, Serialize};
10
11pub mod handle;
12pub mod memory;
13
14pub use handle::{
15 plan_eviction, plan_spool, EvictionOp, EvictionPlan, Handle, HandleId, HandleKind, HandleTable,
16 Residency, SpoolDecision,
17};
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
21#[serde(rename_all = "snake_case")]
22pub enum MemoryTierHint {
23 Durable,
25 Semantic,
27}
28
29impl MemoryTierHint {
30 pub fn label(self) -> &'static str {
31 match self {
32 Self::Durable => "durable",
33 Self::Semantic => "semantic",
34 }
35 }
36}
37
38pub fn tier_hint_for_compress(action: PressureAction) -> MemoryTierHint {
40 match action {
41 PressureAction::ContextCollapse | PressureAction::AutoCompact => MemoryTierHint::Semantic,
42 _ => MemoryTierHint::Durable,
43 }
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48pub struct PageInEntry {
49 pub content: String,
50 #[serde(default, skip_serializing_if = "Option::is_none")]
51 pub tokens: Option<u32>,
52 #[serde(default, skip_serializing_if = "Option::is_none")]
53 pub source: Option<String>,
54 #[serde(default, skip_serializing_if = "Option::is_none")]
56 pub key: Option<String>,
57 #[serde(default, skip_serializing_if = "std::ops::Not::not")]
59 pub pinned: bool,
60}
61
62#[cfg(test)]
63mod tests {
64 use super::*;
65
66 #[test]
67 fn tier_hint_maps_auto_compact_to_semantic() {
68 assert_eq!(
69 tier_hint_for_compress(PressureAction::AutoCompact),
70 MemoryTierHint::Semantic
71 );
72 assert_eq!(
73 tier_hint_for_compress(PressureAction::SnipCompact),
74 MemoryTierHint::Durable
75 );
76 }
77
78}