mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 22:28:10 +09:00
Dream-cycle #2763 (OAS memory-operator selection +48%): consolidation performance jumps when the caller picks the RIGHT operator for the current budget + workload, instead of always applying the fanciest. Ruflo has four consolidation operators (merge/summarize/compress/ distill) but no cost-aware selector — every consolidate call takes the same path. v1 MVP: rule-based selector, three rules: 1. Hint-driven pick when the hinted operator fits the budget. 2. Otherwise, most-expensive-that-still-fits — spend the whole budget on the best-fidelity operator we can afford. 3. When nothing fits across the full entry set, fall back to merge with needsSplit + a batch size ≤ what the budget pays for. Operator taxonomy + estimated cost per entry (in "operator points", 1 point ≈ 1 Haiku call): merge 0.02 pts/entry, max 5000/call — near-duplicate deterministic summarize 0.5 pts/entry, max 500/call — short-to-long via Haiku compress 1.5 pts/entry, max 200/call — LoRA/EWC-style distill 3 pts/entry, max 100/call — pattern extraction for ReasoningBank Standalone CLI: `ruflo memory select-operator --budget N --entries K [--hint duplicates|verbose|patterns|general]`. \`--format json\` for pipelines; text output shows the winner + all four operators ranked by cost so the caller can see the tradeoff. Advisory only in v1: no automatic wire into `memory consolidate` (same safety pattern as #2760 SCM classifier — don't mutate existing consolidation paths in the same release that introduces the selector). v2 wires it into `memory consolidate --auto-operator`. E2E: b=50 e=100 general → summarize (100×0.5=50, fits exactly) b=500 e=50 general → distill (50×3=150, most-expensive-fit) b=5 e=500 duplicates → merge (budget-too-small fallback, split=100) b=50 e=100 patterns → summarize (distill=300 doesn't fit; hint ignored) b=500 e=200 general → distill with needsSplit (200 > max 100) Regression tests: 7/7 pass (rule 1 hint-fit, rule 2 best-fit, rule 3 fallback, hint-ignored-when-doesn't-fit, considered list ranking, needsSplit correctness). Refs: dream-cycle #2763 (2026-07-23). Co-Authored-By: RuFlo <ruv@ruv.net>