Skip to content

feat(core): segment-level consolidation planner, measure-only (#1088) - #1092

Merged
ajianaz merged 1 commit into
developfrom
feat/segment-consolidation-plan
Aug 25, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/segment-consolidation-plan

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a consolidation planner (room_consolidation_plan) that turns semantic room segments (from #1090/#1091) into LLM batching plans with cost estimates — without making any LLM calls.

  • New module consolidation_plan (uteke-core): ConsolidationPlan, PlannedBatch, CostEstimate
  • Per-segment payload = joined memory contents (\n---\n), estimated tokens (~4 chars/token)
  • Cost comparison: naive per-memory calls vs segment-batched calls (call & token reduction)
  • consolidation_plan_from() variant accepts caller-supplied memories (no double query)

Why

Phase 3 of adopting LycheeMemory V2 segment-level consolidation (arXiv:2608.12990, issue #1088). Before wiring real LLM execution into consolidation, we need an evaluation artifact: how many calls/tokens would batching actually save per room. This PR delivers that measurement layer — the executor follows once numbers are reviewed.

Validated on read-only clone of prod DB: rooms with n≥5 memories show 67–91% call reduction (e.g. wa-group n=122 → 14 batches, content-research n=36 → 5 batches).

Testing

  • 3 new unit tests: two-topic bucketing + cost math, empty room, unembedded memories (min_size merge path)
  • Full suite: 502/502 passed, fmt + clippy clean, cora review in pre-commit passed

Adds room_consolidation_plan(): builds per-segment LLM batching plans
from the semantic segmentation (LycheeMemory V2) with call/token cost
estimates — zero LLM calls. Validated on clone prod DB: large rooms
show 67-91% call reduction vs naive per-memory consolidation.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 5052c32 into develop Aug 25, 2026
13 checks passed
@ajianaz
ajianaz deleted the feat/segment-consolidation-plan branch August 25, 2026 01:45
ajianaz added a commit that referenced this pull request Sep 6, 2026