1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! Param and response types for the cache admin MCP tools (`cache_stats`,
//! `cache_gc`, `cache_clear`).
//!
//! Split out of `types.rs` to keep that file under the 1000-line cap. The
//! response structs mirror the `store_gc` layer's `Serialize`-only structs and
//! add the `JsonSchema` derive the MCP surface requires.
use rmcp::schemars;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, schemars::JsonSchema)]
pub struct CacheStatsParams {}
/// MCP-facing mirror of [`crate::store_gc::CacheStats`]. The store-layer struct
/// derives `Serialize` but not `JsonSchema`; this clone adds the schema derive the
/// MCP surface needs and converts via [`From`].
#[derive(Debug, Serialize, schemars::JsonSchema)]
pub(super) struct CacheStatsResponse {
/// Recursive byte size of `blobs/`.
pub blobs_bytes: u64,
/// Recursive byte size of `views/`.
pub views_bytes: u64,
/// Recursive byte size of `lance/`.
pub lance_bytes: u64,
/// Recursive byte size of `git-cache/`.
pub git_cache_bytes: u64,
/// Byte size of `telemetry.jsonl`.
pub telemetry_bytes: u64,
/// Total blob files on disk (every suffix counts as one file).
pub blob_count: usize,
/// Blob files whose hex stem is referenced by no view — reclaimable by `cache_gc`.
pub orphan_blob_count: usize,
/// Per-view indexed file count, `(view_name, file_count)`.
pub per_view_file_count: Vec<(String, usize)>,
}
impl From<crate::store_gc::CacheStats> for CacheStatsResponse {
fn from(s: crate::store_gc::CacheStats) -> Self {
Self {
blobs_bytes: s.blobs_bytes,
views_bytes: s.views_bytes,
lance_bytes: s.lance_bytes,
git_cache_bytes: s.git_cache_bytes,
telemetry_bytes: s.telemetry_bytes,
blob_count: s.blob_count,
orphan_blob_count: s.orphan_blob_count,
per_view_file_count: s.per_view_file_count,
}
}
}
#[derive(Debug, Deserialize, Serialize, schemars::JsonSchema)]
pub struct CacheGcParams {}
/// MCP-facing mirror of [`crate::store_gc::GcReport`] — see [`CacheStatsResponse`]
/// for why the store struct's `JsonSchema` is re-derived here.
#[derive(Debug, Serialize, schemars::JsonSchema)]
pub(super) struct CacheGcResponse {
/// Total blob files inspected.
pub scanned: usize,
/// Orphan blob files removed.
pub removed: usize,
/// Bytes reclaimed by the removals.
pub bytes_freed: u64,
}
impl From<crate::store_gc::GcReport> for CacheGcResponse {
fn from(r: crate::store_gc::GcReport) -> Self {
Self {
scanned: r.scanned,
removed: r.removed,
bytes_freed: r.bytes_freed,
}
}
}
#[derive(Debug, Deserialize, Serialize, schemars::JsonSchema)]
pub struct CacheClearParams {
/// Component to clear: `blobs|views|lance|git-cache|telemetry|all`.
pub component: String,
/// Required gate for the destructive components (`blobs`, `views`) that back
/// the live code map. Ignored for the non-live caches.
#[serde(default)]
pub confirm: bool,
}
#[derive(Debug, Serialize, schemars::JsonSchema)]
pub(super) struct CacheClearResponse {
/// Canonical token of the component that was targeted.
pub component: String,
/// True when the component was actually cleared.
pub cleared: bool,
}