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, Default)]
52pub struct PageInRequest {
53 pub call_id: String,
54 pub tool: String,
55 pub query: String,
56 pub top_k: u32,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize)]
61pub struct PageInEntry {
62 pub content: String,
63 #[serde(default, skip_serializing_if = "Option::is_none")]
64 pub tokens: Option<u32>,
65 #[serde(default, skip_serializing_if = "Option::is_none")]
66 pub source: Option<String>,
67 #[serde(default, skip_serializing_if = "Option::is_none")]
69 pub key: Option<String>,
70 #[serde(default, skip_serializing_if = "std::ops::Not::not")]
72 pub pinned: bool,
73}
74
75#[cfg(test)]
76mod tests {
77 use super::*;
78
79 #[test]
80 fn tier_hint_maps_auto_compact_to_semantic() {
81 assert_eq!(
82 tier_hint_for_compress(PressureAction::AutoCompact),
83 MemoryTierHint::Semantic
84 );
85 assert_eq!(
86 tier_hint_for_compress(PressureAction::SnipCompact),
87 MemoryTierHint::Durable
88 );
89 }
90
91}