Files
ruflo/v3/@claude-flow/cli/src/swarm
ruv 3280cf423e feat(swarm): inter-agent message compressor — IB+VQ MVP (#2727 dream)
Dream-cycle #2727 (IB+VQ messaging 181.8% task gain): variable-
bandwidth compression at the inter-agent message boundary breaks the
performance/bandwidth tradeoff. Real VQ needs a codebook trained on
actual agent traffic (own PR + own dataset). This v1 MVP delivers
the paper's SPIRIT via a deterministic pipeline that ships now:

  1. Extract must-preserve spans (code fences, inline code, URLs,
     file paths) — replace with opaque placeholders.
  2. Split remaining text into sentences; score by TF-IDF-ish
     keyword density (with a domain stop-list) + optional lead
     bias, mode-selectable.
  3. Force-keep every sentence carrying a placeholder (they're
     load-bearing — dropping them orphans the preserved span).
  4. Fill the remaining budget with top-scored sentences.
  5. Reassemble in ORIGINAL sentence order + restore spans.

New CLI subcommand: `ruflo swarm compress-message`
  -m, --message "..."     inline message
  --message-file <path>   file contents
  -b, --budget-tokens N   target budget (default 200)
  --mode keyword|sentence|hybrid   (default hybrid: 0.7·keyword + 0.3·sentence)

Advisory only in v1 — no auto-wire into SendMessage / hooks (same
safety pattern as #2760 SCM + #2763 OAS). v2 will land a real VQ
codec once the training pipeline exists.

E2E:
  106-token message with a code fence + URL + file path
  → 57 tokens (53.1% ratio); all 3 preserved spans present
  → load-bearing sentences kept; verbose filler dropped

Regression tests: 9/9 pass (code-fence preservation, URL preservation,
file-path preservation, budget reduction, sentence-count accuracy,
order preservation, no-op when budget > original, tokenizer sanity,
keyword vs sentence mode).

Refs: dream-cycle #2727 (2026-07-19).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-07-26 23:15:00 -04:00
..