Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

Skip caching control plugins during mount (#2948)

tuofangdd5b1d7a7f60
diff --git a/crates/ragfs/src/core/mountable.rs b/crates/ragfs/src/core/mountable.rs
index 6cc493e0d..08dc4e1b2 100644
--- a/crates/ragfs/src/core/mountable.rs
+++ b/crates/ragfs/src/core/mountable.rs
@@ -286,7 +286,8 @@ impl MountableFS {
None => {
// Single backend: initialize plugin, optionally wrap raw storage with cache, then
// wrap with encryption. This keeps shared cache providers ciphertext-only.
- // Control plugins (queuefs, serverinfofs) are never encrypted.
+ // Control plugins (queuefs, serverinfofs) are dynamic virtual filesystems; never
+ // cache or encrypt them.
let raw = plugin.initialize(config.clone()).await?;
let raw_arc: Arc<dyn FileSystem> = Arc::from(raw);
let is_control_plugin = matches!(config.name.as_str(), "queuefs" | "serverinfofs");
@@ -301,7 +302,11 @@ impl MountableFS {
.await?;
}
#[cfg(feature = "cache")]
- let storage_fs = self.maybe_wrap_cache(raw_arc.clone(), &normalized_path);
+ let storage_fs = if is_control_plugin {
+ raw_arc.clone()
+ } else {
+ self.maybe_wrap_cache(raw_arc.clone(), &normalized_path)
+ };
#[cfg(not(feature = "cache"))]
let storage_fs = raw_arc.clone();
@@ -1284,6 +1289,52 @@ mod tests {
assert_eq!(reads.load(Ordering::Relaxed), 1);
}
+ #[cfg(feature = "cache")]
+ #[tokio::test]
+ async fn queuefs_mount_bypasses_cache_even_when_cache_is_configured() {
+ use crate::cache::{CacheNamespace, CachePolicy, MemoryCacheProvider};
+ use crate::plugins::QueueFSPlugin;
+
+ let provider = Arc::new(MemoryCacheProvider::new());
+ let mfs = MountableFS::with_cache(
+ provider.clone(),
+ CacheNamespace::new("queue-cache-test"),
+ CachePolicy::default().with_bypass_prefix("/queue"),
+ );
+ mfs.register_plugin(QueueFSPlugin::new()).await;
+ mfs.mount(PluginConfig::single_backend(
+ "queuefs",
+ "/queue",
+ HashMap::new(),
+ ))
+ .await
+ .unwrap();
+ mfs.mkdir("/queue/Embedding", 0o755).await.unwrap();
+
+ assert_eq!(
+ mfs.read("/queue/Embedding/size", 0, 0).await.unwrap(),
+ b"0"
+ );
+ mfs.write(
+ "/queue/Embedding/enqueue",
+ br#"{"id":"one"}"#,
+ 0,
+ WriteFlag::Create,
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(
+ mfs.read("/queue/Embedding/size", 0, 0).await.unwrap(),
+ b"1",
+ "queuefs size is dynamic and must not be served from cache"
+ );
+ assert!(
+ provider.keys().await.is_empty(),
+ "queuefs control filesystem should not populate shared cache"
+ );
+ }
+
#[cfg(feature = "cache")]
#[tokio::test]
async fn copy_within_mount_overwrite_invalidates_cached_destination() {