yams/tests/benchmarks/xplan
Trevon 3f37e8f564
Sync experimental into main: Search retrieval improvements (#60)
* fix(graph): handle qualified C++ symbols

Signed-off-by: trvon <me@trevon.dev>

* refactor(vector)!: remove dead transition APIs

Split Simeon vector and retrieval linkage so consumers inherit only the runtime surface they use.

BREAKING CHANGE: remove unused async/model/config helpers and the undefined vector-backend factory from public headers.

Signed-off-by: trvon <me@trevon.dev>

* fix(vector): harden PQ snapshot lifecycle

Validate and atomically install persisted generations, revalidate after races, and fall back to exact search when a snapshot is stale. Add the exact-scan reference lane and distinguish observed work counters from unavailable backend metrics.

Signed-off-by: trvon <me@trevon.dev>

* feat(topology): expose route coordinates

Persist chart distortion and local-dimension evidence, retain pre-scalarization route axes, and emit detailed trace rows without treating unavailable vector work as zero.

Signed-off-by: trvon <me@trevon.dev>

* feat(xplan): add vector decision gates

Track binary and corpus identity, preserve missing-work semantics, and add repeated PQ routing, crossover, and rerank plans with quality and cost summaries.

Signed-off-by: trvon <me@trevon.dev>

* feat(topology): formalize coordinate routing

Separate chart geometry from route-risk admission and prove candidate-stage recall and strict-focus boundaries. Record the measured atlas limitations and literature basis for the next construction experiment.

Signed-off-by: trvon <me@trevon.dev>

* fix(search): serialize SymSpell readers

SQLite-backed lookups reuse mutable prepared statements, so shared-reader locking is unsafe. Advance the owned SymSpell revision for batched delete insertion and cover concurrent root lookups under TSAN.

Signed-off-by: trvon <me@trevon.dev>

* fix(vector): make mutations atomic

Preserve stored vectors on replacement and commit failures, reject cross-thread writes during explicit transactions, and restore exact reranking for quantized-primary PQ rows.

* fix(search)!: surface SymSpell write errors

Propagate persistent dictionary failures through metadata ingestion, roll back failed batches, and make clear remove stored terms.

BREAKING CHANGE: SymSpellSearch mutations now return Result values.

* feat(topology): formalize candidate expansion

* feat(vector): add coordinate-aware embeddings

* feat(topology): preserve protected relation cover

* feat(search): add graph candidate rescue

* feat(daemon): expose retrieval hydration telemetry

* feat(xplan): add rescue and hydration gates

* refactor(content): dedupe media handlers

Reuse shared graph presenter helpers and centralize repeated audio/video/archive buffer processing, validation, lifecycle, and stats helper logic.

* feat(lifecycle): prune stale corpus data

Keep cleanup preview-first while retention stays opt-in and long prune work no longer holds IPC responses open.

* feat(search): add topology candidate rescue

Preserve high-value routed candidates across vector backends while keeping exact rerank diagnostics explicit.

* feat(search): expose evidence paths

* docs: define mobile host contract

* formal: model bounded candidate rescue

* fix(prune): inspect extensionless signatures

* fix(prune): tolerate stale extensions

---------

Signed-off-by: trvon <me@trevon.dev>
2026-07-24 19:00:22 -04:00
..
plans Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
schema feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
workers Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
__init__.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
analyze_query_class.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
artifacts.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
model.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
README.md Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
report.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00
runner.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
summarize.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
test_hydration_metrics.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
test_xplan_contracts.py Sync experimental into main: Search retrieval improvements (#60) 2026-07-24 19:00:22 -04:00
validate.py feat(search): make topology-assisted retrieval the default (#57) 2026-07-13 20:26:43 -04:00

xplan (engineering)

Unified multi-arm experiment runner for daemon KPI work. Not a product surface.

Commands

python3 tests/benchmarks/xplan/runner.py self-test
python3 tests/benchmarks/xplan/runner.py list-plans
python3 tests/benchmarks/xplan/runner.py list-workers

# BEIR corpora for quality/topology plans (auto-fetched on first run too)
python3 tests/benchmarks/xplan/runner.py download-beir            # scifact + nfcorpus
python3 tests/benchmarks/xplan/runner.py download-beir scifact
python3 tests/benchmarks/xplan/runner.py download-beir --list

# Run a plan (writes artifacts under build/benchmarks/)
python3 tests/benchmarks/xplan/runner.py run <plan> --build-dir build/release
python3 tests/benchmarks/xplan/runner.py run <plan> --dry-run
python3 tests/benchmarks/xplan/runner.py run <plan> --arm baseline --arm no_kg

# Regenerate docs for an existing artifact directory
python3 tests/benchmarks/xplan/runner.py report build/benchmarks/<plan>/<stamp>

# Compare two stamps
python3 tests/benchmarks/xplan/runner.py compare \
  build/benchmarks/ingest_pipeline/<stampA> \
  build/benchmarks/ingest_pipeline/<stampB>

Generated report files (per run)

File Contents
REPORT.md Full engineering report: host/git, primary + all metrics, factors, per-arm detail
ablation.md Baseline vs other arms, relative deltas, ranking hints
metrics.csv Flat table for spreadsheets
report.json Machine-readable full report
summary.md / summary.json Compact overview
arms/<arm>/metrics.json Per-arm KPIs + ablation attributes

All under build/benchmarks/<plan>/<stamp>/ (gitignored).

Layout

tests/benchmarks/xplan/
  runner.py          # CLI
  plans/*.json       # experiment definitions
  workers/           # measurement adapters + ablation.py
  report.py          # REPORT.md / ablation.md / csv
  summarize.py       # compact summary + report hook
  schema/            # plan schema

Ablation

workers/ablation.py maps plan factors → env (one-factor-off):

  • Search components: YAMS_SEARCH_*_WEIGHT=0 + YAMS_ENABLE_ENV_OVERRIDES=1
  • Ingest: YAMS_BENCH_DISABLE_KG, YAMS_DISABLE_VECTORS, GLiNER
  • Topology mode / expansion presets (full64, medoid64, cap8, cap2) in retrieval_quality

Plans (engineering)

Plan Focus
search_component_ablation / subsystem_overhead Search engine component one-factor-off (BEIR scifact)
leg_stage_ablation / simeon_rerank* Search pipeline / rerank arms
ingest_pipeline Ingest kg/vectors/gliner (synthetic — throughput, not ranking)
retrieval_load / repair_ability / ops_timeline / daemon_ops_core Daemon KPIs 2–5
retrieval_hydration_pressure Search snippet lookup/content-fetch/render plus grep match-render and graph snippet-render p50/p95/p99 under concurrent writes; paths-only search control (repeats=3)
read_write_pressure Equal-budget write-heavy/balanced/read-heavy/read-only daemon load; per-op latency, DB pools, WriteCoordinator pressure, WAL growth, drain, and recovery (repeats=3)
topology_purity_validate / topology_routing_budget_ablation Topology construction purity and routed-vs-global ANN budget gate (repeats=3)
search_generalized_memory_topology_gate SciFact + NF-Corpus in one index; per-source quality, cross-source interference, and topology-vs-global cost (repeats=3)
search_simeon_ann_attribution_multicorp Mixed-corpus text/current-PQ/exact-vec0 attribution over identical Simeon embeddings (repeats=3)
plans/archive/* Superseded plans (historical only)

Agent measurement loop and plan selection: repo AGENTS.md (Benchmarks & Experiments).

Corpora

Kind Used by Notes
BEIR scifact (default for quality) search_component_*, topology_*, simeon_rerank*, leg_stage_* ~/.cache/yams/benchmarks/scifact; auto-download on run
BEIR nfcorpus optional plan override dataset=nfcorpus same cache layout
Mixed BEIR memory search_generalized_memory_topology_gate one daemon/index containing namespaced SciFact + NF-Corpus documents and queries
synthetic ingest/load/ops throughput only not for ranking ablations — opt-in via "dataset": "synthetic"

Default quality params: dataset=scifact, corpus_size=2000, num_queries=50.

Plans with separate SciFact and NF-Corpus arms test transfer between isolated indexes; they do not model generalized memory. A retrieval-quality plan can set datasets to two or more BEIR names to materialize one content-deduplicated local-manifest for the entire run. The worker namespaces document/query IDs, remaps duplicate-content qrels, and reports per-source MRR/recall plus mixed_cross_source_result_rate and mixed_cross_source_top1_rate from the shared ranking. The benchmark also exports topology_clusters.json and derives mixed_cluster_overlap.json, which shows source counts, entropy, and purity for every cluster. Aggregate metrics distinguish the fraction of cross-source clusters from the fraction of documents exposed to those clusters; content duplicated across corpora is reported separately and excluded from partition purity.

For state-sensitive search ablations, shared_warm_cache primes one immutable YAMS store and clones it into each measured arm/repeat. This fixes corpus, vector index, tuner state, and persisted topology without letting one workload mutate the next workload's input. Topology plans can also set require_topology_construction_identity=true; the worker pins the first construction fingerprint and fails on within-workload, cross-repeat, or cross-arm drift. Do not point multiple measured arms at one live warm directory: that preserves topology but carries mutable query/tuner state forward.

Evaluate ingestion changes in two lanes at the same code revision. Use search_generalized_memory_topology_gate after the index settles for mixed-memory quality and route purity. Use retrieval_load for concurrent adds/searches through the daemon; it reports post-ingest backlog plus WriteCoordinator queue depth, in-flight work, apply time, queue wait, and excess queue wait. Do not combine these into one score: promote an ingestion change only when it preserves the per-source quality floor and improves or holds the read-under-write pressure KPIs.

Use read_write_pressure when the question is contention rather than search-component attribution. Its arms execute the same operation budget per client, vary only the read/write mix, and subtract a post-warmup infrastructure baseline from cumulative queue/WAL counters. Point-in-time queue depth and the workload high-water delta are both retained so short bursts are not hidden by sampling. Set harness-only YAMS_BENCH_CORPUS_SEED_DIR to a frozen YAMS data directory to give every arm/repeat an isolated copy-on-write corpus; YAMS_BENCH_SEARCH_QUERY can select a representative symbol or concept. The source directory is never opened by the daemon and remains unchanged.

Rules

  • No new multi-arm shell scripts. Wrappers under scripts/ only.
  • Prefer typed config for product knobs; YAMS_BENCH_* is harness-only.
  • Do not rank search levers on synthetic — BEIR only (or another labeled hard corpus).
  • Topology claims need debug.jsonl counters / certificates.
  • Multi-client plans need a Catch2-enabled builddir.
  • Published numbers: docs/benchmarks/README.md (default system only).

Known infrastructure debt

  • yams graph --explore can fail with a local index SQL logic error for valid readiness symbols (observed on SearchEngineManager::getSnapshot / rebuildNow). The fallback is a targeted local read after YAMS retrieval identifies the files. Follow-up: capture yams doctor diagnostics, verify graph/index schema integrity, and add a regression fixture before changing graph-query behavior.