v3/docs/adr/ADR-360-dream-cycle-performance-polykv-shared-kv-pool.md
Ruflo currently maintains per-agent KV caches with no cross-agent sharing or compression. At 15+ concurrent agents, the per-agent approach accumulates memory linearly — a 4K-token context per agent on Llama-3-8B scale requires ~19.8 GB of KV memory for 15 agents under the default (unshared) model.
PolyKV (arXiv:2604.24971, Patel & Joshi, Apr 2026) proves that a shared asymmetrically-compressed KV pool collapses this to 0.45 GB (97.7% reduction) with 2.91x compression via int8 key quantization + FWHT + 3-bit Lloyd-Max value quantization, while preserving BERTScore F1 of 0.928 and perplexity degradation of only +0.57%. This is a Grade A finding (two model scales tested with specified baselines).
Two complementary findings reinforce the case for serving-layer changes:
The @claude-flow/memory package owns AgentDB + HNSW vector indexing but does not manage KV caches for LLM inference contexts. Adding a shared compressed pool requires a new coordination layer between the memory package and the CLI's agent execution path.
Implement a SharedKVPoolManager in @claude-flow/memory that:
(model, context_hash)kvpool:// pseudo-backend selectable via CLAUDE_FLOW_KV_BACKEND=shared-poolhybrid memory backend — pool lives alongside SQLite + AgentDBpool_hit_rate, pool_memory_bytes, compression_ratio) to the performance monitoring hookPositive:
@claude-flow/memory)Negative / Risks:
Neutral:
v3/@claude-flow/memory/src/kv-pool/ — new module: SharedKVPoolManager, AsymmetricKVCodec (int8 keys + FWHT+Lloyd-Max values), KVEvictionPolicy (LRU)v3/@claude-flow/memory/src/index.ts — export SharedKVPoolManager; register kvpool:// backendv3/@claude-flow/cli/src/commands/performance/ — add kv-pool subcommand (status, flush, benchmark)scripts/benchmark-kv-pool.mjs — measure pool vs per-agent baseline at N=5,10,15 agents; gate merge on ≥90% memory reduction and BERTScore F1 ≥0.90CLAUDE.md performance table — add row once benchmark validates