Skip to content

feat: benchmark suite — uteke bench + LongMemEval harness (#49, #316) - #320

Merged
ajianaz merged 3 commits into
developfrom
feat/benchmark-49-316
Jun 13, 2026
Merged

ajianaz merged 3 commits into
developfrom
feat/benchmark-49-316

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #49, Closes #316

#49 — Performance benchmark command

uteke bench generates synthetic memories and measures performance at scale:

uteke bench                              # default: 100, 1000, 10000
uteke bench --counts 500,5000            # custom counts
uteke bench --json                       # machine-readable

Measures:

  • Insert throughput (ops/sec)
  • Recall latency (avg + p95)
  • DB size, index size

Implementation:

  • Deterministic xorshift64* PRNG (no rand dependency)
  • Synthetic content generator with word banks
  • RAII temp dir cleanup (no leaks on failure)
  • Counts capped at 100K to prevent runaway

#316 — LongMemEval retrieval harness

benchmarks/longmemeval/ evaluates uteke retrieval accuracy against the LongMemEval benchmark (ICLR 2025):

cd benchmarks/longmemeval
./download_data.sh
pip install -r requirements.txt
python run_eval.py --data data/longmemeval_oracle.json
python print_metrics.py results/retrieval_results.jsonl

Measures:

  • Session-level Recall@5/10/50
  • Session-level NDCG@5/10/50
  • Per-question-type breakdown (single-session, multi-session, knowledge-update, temporal)

Files:

  • run_eval.py — inserts sessions into uteke, runs recall, evaluates
  • print_metrics.py — aggregates and prints results + README table
  • download_data.sh — downloads dataset from HuggingFace
  • RESULTS.md — comparison table vs Mem0/Hindsight

Cora review fixes applied:

  • ✅ Temp dir leak on failure → RAII TempDirGuard
  • ✅ Unbounded counts → capped at 100K
  • ✅ Double dispatch in mod.rs → removed
  • ✅ Failed inserts counted as evidence → filter to inserted_sids
  • ✅ Forget failure not handled → wipe store on failure
  • ✅ Turn-level metrics copied from session → omitted (honest)

Tests

  • cargo test --workspace ✅ (134 passed, 5 ignored for ONNX model)
  • cargo clippy --workspace -- -D warnings ✅
  • cargo fmt --all -- --check ✅
  • Python syntax check ✅


Answer correctness evaluation (optional) uses GPT-4o via the official LongMemEval script:
```bash
export OPENAI_API_KEY=your_key
] + subcommand
if extra_args:
cmd += extra_args
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
Comment thread benchmarks/longmemeval/run_eval.py Fixed
Comment thread benchmarks/longmemeval/run_eval.py Fixed
Comment thread docs/cli-reference.md
uteke bench --json
```

Measures insert throughput, recall latency (avg + p95), and storage footprint.
@github-actions

github-actions Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (6)

  • benchmarks/longmemeval/run_eval.py:83 — The README and module comments say each session is inserted with its session date, but insert_sessions() only stores the date inside --meta (meta_parts.append(f"date:{date}")) and never passes a timestamp argument to uteke remember. This means retrieval is evaluated on memories with insertion-time timestamps instead of dataset timestamps, which can materially skew temporal-reasoning and knowledge-update benchmark results.
  • benchmarks/longmemeval/run_eval.py:133 — In recall_and_evaluate(), retrieved_session_ids is built by appending every hit's session_id, then Recall@k is computed with hits = len(set(top_k) & evidence_session_ids). If uteke recall returns multiple memories from the same evidence session in the top-k, they occupy several slots but still count as one hit, reducing ranking diversity. More importantly, because the harness indexes whole sessions as single memories today this may be hidden, but any future change to store multiple memories per session would make the metric inconsistent with session-level retrieval. The code should explicitly deduplicate retrieved session IDs while preserving order before slicing top-k.
  • crates/uteke-cli/src/commands/bench.rs:152 — run_bench() caps every requested count with c.min(MAX_COUNT). A user asking for --counts 250000 will get a 100000-memory run without any warning, producing misleading output because the reported count no longer matches the requested benchmark scale. Since this is a benchmarking command, silently changing the workload undermines the correctness of the results.
  • benchmarks/longmemeval/README.md:68 — Static security scanner detected: Hardcoded password or secret in variable in benchmarks/longmemeval/README.md:68
  • benchmarks/longmemeval/run_eval.py:55 — Static security scanner detected: Command injection via exec/system with dynamic input in benchmarks/longmemeval/run_eval.py:55
  • docs/cli-reference.md:283 — Static security scanner detected: SQL injection via string concatenation in docs/cli-reference.md:283

Review powered by cora-cli · BYOK · MIT

ajianaz added 3 commits June 13, 2026 21:23
- CLI: `uteke bench` with --counts and --json flags
- Benchmarks: insert throughput, recall latency (avg+p95), storage footprint
- Deterministic xorshift64* PRNG (no rand dep)
- Synthetic content generator with word banks
- Human-readable table + JSON output
- Temp stores auto-cleaned up

Closes #49
- benchmarks/longmemeval/ harness: run_eval.py + print_metrics.py
- Downloads dataset from HuggingFace (download_data.sh)
- Measures session-level Recall@5/10/50, NDCG@5/10/50
- Per-question-type breakdown (single-session, multi-session, knowledge-update, etc.)
- benchmarks/RESULTS.md: comparison table vs Mem0/Hindsight
- README.md with quick-start guide

Closes #316
@ajianaz
ajianaz force-pushed the feat/benchmark-49-316 branch from 7c074e5 to d83dfed Compare June 13, 2026 14:23

# Use --meta for session_id and date
meta_parts = [f"session_id:{sid}"]
if date:
return None

# Parse results
try:
}

/// Run the benchmark across multiple memory counts.
///
@ajianaz
ajianaz merged commit 9806682 into develop Jun 13, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the feat/benchmark-49-316 branch June 13, 2026 14:30
ajianaz added a commit that referenced this pull request Jun 13, 2026
* feat(#304,#305): semantic room recall + LLM-free room summary (#309)

#304 — Semantic room recall:
- recall_room_semantic() uses hybrid RRF search scoped to room memories
- `uteke room recall <room> --query "..." --min 0.5` ranks by relevance
- POST /room/recall server endpoint
- Backward compatible: without --query, chronological dump unchanged

#305 — Room summary (LLM-free topic clustering):
- room_summary() clusters memories by tag co-occurrence
- Extracts: topic clusters, top tags, recent decisions, pinned highlights
- `uteke room summary <room>` — human + JSON output
- POST /room/summary server endpoint

9 files changed, +627 lines

* feat: v0.1.0 remaining — tag junction, room document, pluggable embedding, time-travel (#314)

* feat(#184): normalize tags with junction table (schema v5)

- New memory_tags table with COLLATE NOCASE for O(log n) lookups
- Migration v4→v5: creates table, populates from existing JSON tags
- Dual-write: insert/update writes to both JSON column and junction table
- All tag queries use junction table instead of json_each()
- Backward compat: JSON tags column preserved

5 files changed in uteke-core.

* feat(#306): room document view — structured output from room memories

- RoomDocument with sections grouped by memory_type
- DocumentSection: heading + icon (📋 Decisions, 🔍 Facts, ⚙️ Procedures, etc)
- Pinned memories get 📌 section first
- CLI: `uteke room document <room>` — markdown-style human output + JSON
- Server: POST /room/document endpoint
- Types exported from uteke-core

Closes #306

* fix(#306): bound room document query to 10K, fix non-ASCII truncation panic

* feat(#249): pluggable embedding models via Embedder trait

- New Embedder trait (Send + Sync) in embed_trait.rs
- EmbeddingEngine renamed to OnnxEmbedder
- Tokenizer + Session wrapped in Mutex for &self embed()
- Uteke struct uses Box<dyn Embedder>
- Config: [embedding] backend field (default: "onnx")
- Uteke::open_with_backend() selects backend via lazy init
- Backward compat: EmbeddingEngine type alias = OnnxEmbedder
- Future: OpenAI/Ollama backends implement Embedder trait

* feat(#249): pluggable embedding models via Embedder trait

- New Embedder trait (Send + Sync) in embed_trait.rs
- EmbeddingEngine renamed to OnnxEmbedder
- Tokenizer + Session wrapped in Mutex for &self embed()
- Uteke struct uses Box<dyn Embedder>
- Config: [embedding] backend field (default: "onnx"), validated at startup
- Uteke::open_with_backend() + open_with_tier_and_backend()
- Lazy init selects backend by name, error on unknown
- Backward compat: EmbeddingEngine type alias = OnnxEmbedder
- Future: OpenAI/Ollama implement Embedder trait

Closes #249

* feat(#292): time-travel queries — recall/list memories at a point in time

- Store::list_at_time(): SQL temporal filter on created_at, valid_from,
  valid_until, deprecated
- Uteke::recall_at_time(): over-fetch + post-filter by temporal validity
- Uteke::list_at_time(): thin wrapper to store
- CLI: --at flag on recall and list commands (RFC3339 parsing)
- Server: /recall and /list endpoints accept 'at' field
- Server proxy: passes --at through to server
- 4 unit tests covering all temporal edge cases

Closes #292

* fix(#292): retry loop for temporal recall to fill requested limit

Over-fetch with increasing multipliers (3x, 9x, 27x) when temporal
post-filtering yields fewer results than requested. Detects index
exhaustion to avoid pointless retries.

Addresses Cora review: temporal recall can return too few results.

* fix(#292): stop retry on index exhaustion regardless of result count

Index exhaustion = candidates_len < fetch_limit. When this happens,
expanding the search scope cannot yield more results. Previously
only stopped when results.is_empty(), which missed the case where
partial results exist but the index has no more candidates.

* feat(#292): time-travel queries — recall and list at specific point in time

- recall_at_time(): semantic recall with temporal validity filter
- list_at_time(): list memories that existed at timestamp
- Temporal logic: created_at <= pit, valid_from/valid_until, not deprecated
- CLI: --at flag on recall and list commands (RFC3339 format)
- Server: /recall and /list accept "at" field
- 4 new store tests for temporal filtering
- Retry loop expands fetch limit when temporal filter removes too many

Closes #292

* docs: update for v0.1.0 — rooms, time-travel, pluggable embeddings, tag junction (#315)

* docs: update branch protection rules for main and develop branches (#308)

Co-authored-by: ajianaz <[email protected]>

* feat: benchmark suite — uteke bench + LongMemEval harness (#49, #316) (#320)

* feat(#49): uteke bench command — synthetic performance benchmarking

- CLI: `uteke bench` with --counts and --json flags
- Benchmarks: insert throughput, recall latency (avg+p95), storage footprint
- Deterministic xorshift64* PRNG (no rand dep)
- Synthetic content generator with word banks
- Human-readable table + JSON output
- Temp stores auto-cleaned up

Closes #49

* feat(#316): LongMemEval benchmark harness for retrieval accuracy

- benchmarks/longmemeval/ harness: run_eval.py + print_metrics.py
- Downloads dataset from HuggingFace (download_data.sh)
- Measures session-level Recall@5/10/50, NDCG@5/10/50
- Per-question-type breakdown (single-session, multi-session, knowledge-update, etc.)
- benchmarks/RESULTS.md: comparison table vs Mem0/Hindsight
- README.md with quick-start guide

Closes #316

* docs: add bench command + LongMemEval harness to changelog, CLI ref, README

* docs: complete v0.1.0 documentation — index, getting-started, README.id, sidebar (#321)

- docs/index.md: 6 new feature cards (Rooms, Time-Travel, Relationship Graph,
  Smart Decay, MCP Server, Benchmarks) + 7 new comparison table rows
- docs/getting-started.md: 6 new sections (Rooms, Time-Travel Queries,
  Memory Importance & Pinning, Relationship Graph, Recall Cache,
  Benchmarking) + fixed model path to embeddinggemma-q4/onnx/
- README.id.md: synced with English README — v0.1.0 badge, 15 features,
  expanded comparison table with Rooms/Time-travel/MCP/Graph/Decay/Cache/Bench
- docs/.vitepress/config.ts: restructured sidebar into 3 groups
  (Getting Started, Features, Reference) with anchors to new sections

* release: v0.1.0 — version bump, JSON output fix, changelog (#322)

- Version: 0.0.15 → 0.1.0 (workspace + inter-crate deps)
- Fix: recall --json now always outputs [] on empty results (was {"results":[]})
  This ensures cora-cli and other JSON consumers can parse output reliably.
- CHANGELOG: [Unreleased] → [0.1.0] — 2026-06-13

* ci: add CodeCorraDev Roadmap project board auto-sync (#319)

* ci: add project board auto-sync workflow

* fix(ci): harden project-sync workflow for CodeCora findings

- Guard against empty issue fields on workflow_dispatch (use || '')
- Early exit when no issue context (manual dispatch)
- Separate stdout/stderr for GraphQL calls
- Check for 'errors' field in response instead of naive grep 'item'
- Add fallback case for unhandled events

Fixes CodeCora alerts on PR #319.

---------

Co-authored-by: ajianaz <[email protected]>
ajianaz added a commit that referenced this pull request Aug 13, 2026
…#320)

* feat(#49): uteke bench command — synthetic performance benchmarking

- CLI: `uteke bench` with --counts and --json flags
- Benchmarks: insert throughput, recall latency (avg+p95), storage footprint
- Deterministic xorshift64* PRNG (no rand dep)
- Synthetic content generator with word banks
- Human-readable table + JSON output
- Temp stores auto-cleaned up

Closes #49

* feat(#316): LongMemEval benchmark harness for retrieval accuracy

- benchmarks/longmemeval/ harness: run_eval.py + print_metrics.py
- Downloads dataset from HuggingFace (download_data.sh)
- Measures session-level Recall@5/10/50, NDCG@5/10/50
- Per-question-type breakdown (single-session, multi-session, knowledge-update, etc.)
- benchmarks/RESULTS.md: comparison table vs Mem0/Hindsight
- README.md with quick-start guide

Closes #316

* docs: add bench command + LongMemEval harness to changelog, CLI ref, README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants