Commit graph

38 commits

Author SHA1 Message Date
Trevon
577adf1e0f
build: standardize the Debug build dir on build/debug (#248)
* build: standardize the Debug build dir on build/debug

`docs/BUILD.md` and `AGENTS.md` document `./setup.sh Debug` producing
`build/debug`, but `setup.sh`/`setup.ps1` created `builddir` and `.clangd`
pointed there too, so the documented layout and the actual tree disagreed.

Align the Debug mapping with the documented layout:
- setup.sh / setup.ps1: Debug -> `build/debug`
- CMakeLists.txt: Debug `_meson_build_dir` -> `build/debug`
- .clangd: CompilationDatabase -> `build/debug`
- plugin test fallbacks, S3 smoke default, quality-gate candidate list, and
  doc examples -> `build/debug`

Legacy `builddir` trees stay readable: the quality gate and local-ci scripts
still probe `builddir` as a fallback, and `plugin_trust` already treats
`/build/` paths as build artifacts.

* build: migrate remaining Debug consumers off builddir

Follow-up to the Debug build-dir standardization: tracked consumers still
hardcoded `builddir` and would break or silently skip against a fresh
`build/debug` tree. Migrate them, keeping tolerant fallbacks where a legacy
tree may still exist.

- CI: `.github/workflows/tests.yml` runs `./setup.sh Debug` and then compiled
  `-C builddir`; switch BUILD_DIR/COMPILE_DB_DIR/compile paths to `build/debug`.
  Same for windows-test-diagnose.yml.
- IDE: `.vscode/tasks.json` build/test/bench tasks target `build/debug`.
- Runtime: `object_storage_plugin_loader` also probes `build/debug/plugins`
  (and the flat `build/debug`), retaining the `builddir` fallbacks.
- Tests/docs: ONNX tuning integration plugin dir, benchmarks, and plugin
  READMEs/examples use `build/debug`.

`./build/*` is already excluded from the quality-gate find and `.dockerignore`,
so no exclusion lists change.
2026-10-01 08:45:20 -06:00
Trevon
73d408a4a6
[05/14] Consolidate configuration authority (#145)
* refactor(search): retire 45 unreferenced YAMS_SEARCH_* env overlays

LegacySearchConfigEnvironment::applyTo carried 87 YAMS_SEARCH_* overlays
gated behind YAMS_ENABLE_ENV_OVERRIDES. AGENTS.md sanctions them as
test-only benchmark levers, but tests/scripts/report_config_key_usage.py
shows 45 of them are set by no test, no bench arm, no script, and no
doc: they were levers nobody pulled, each shadowing a SearchEngineConfig
field that benches and tests already set directly. The entire
YAMS_SEARCH_GRAPH_* cluster is among them, matching the plan-hygiene
note that graph-vector fusion is a parked lever.

Removed (CANDIDATE rows of the report, verbatim):
  YAMS_SEARCH_BYPASS_CORPUS_WARMING_GATE
  YAMS_SEARCH_ENABLE_GRAPH_FUSION_WINDOW_GUARD
  YAMS_SEARCH_ENABLE_GRAPH_QUERY_EXPANSION
  YAMS_SEARCH_ENABLE_LEXICAL_EXPANSION
  YAMS_SEARCH_ENABLE_WEAK_QUERY_FANOUT_BOOST
  YAMS_SEARCH_FUSION_EVIDENCE_RESCUE_MIN_SCORE
  YAMS_SEARCH_FUSION_EVIDENCE_RESCUE_SLOTS
  YAMS_SEARCH_GRAPH_COMMUNITY_WEIGHT
  YAMS_SEARCH_GRAPH_ENABLE_PATHS
  YAMS_SEARCH_GRAPH_EXPANSION_FTS_PENALTY
  YAMS_SEARCH_GRAPH_EXPANSION_MAX_SEEDS
  YAMS_SEARCH_GRAPH_EXPANSION_MAX_TERMS
  YAMS_SEARCH_GRAPH_EXPANSION_MIN_HITS
  YAMS_SEARCH_GRAPH_EXPANSION_QUERY_NEIGHBOR_K
  YAMS_SEARCH_GRAPH_EXPANSION_QUERY_NEIGHBOR_MIN_SCORE
  YAMS_SEARCH_GRAPH_EXPANSION_VECTOR_PENALTY
  YAMS_SEARCH_GRAPH_FALLBACK_TOP_SIGNAL
  YAMS_SEARCH_GRAPH_FUSION_GUARD_DEPTH_MULTIPLIER
  YAMS_SEARCH_GRAPH_HOP_DECAY
  YAMS_SEARCH_GRAPH_MAX_ADDED_IN_FUSION_WINDOW
  YAMS_SEARCH_GRAPH_MAX_HOPS
  YAMS_SEARCH_GRAPH_MAX_NEIGHBORS
  YAMS_SEARCH_GRAPH_MAX_PATHS
  YAMS_SEARCH_GRAPH_TEXT_MIN_ADMISSION_SCORE
  YAMS_SEARCH_GRAPH_TEXT_WEIGHT
  YAMS_SEARCH_GRAPH_USE_QUERY_CONCEPTS
  YAMS_SEARCH_GRAPH_VECTOR_REQUIRE_BASELINE_TEXT_ANCHORING
  YAMS_SEARCH_GRAPH_VECTOR_REQUIRE_CORROBORATION
  YAMS_SEARCH_GRAPH_VECTOR_REQUIRE_TEXT_ANCHORING
  YAMS_SEARCH_GRAPH_VECTOR_WEIGHT
  YAMS_SEARCH_LEXICAL_EXPANSION_MIN_HITS
  YAMS_SEARCH_LEXICAL_EXPANSION_PENALTY
  YAMS_SEARCH_RERANK_TOP_K
  YAMS_SEARCH_SEMANTIC_RESCUE_MIN_SCORE
  YAMS_SEARCH_STRONG_VECTOR_ONLY_TOP_RANK
  YAMS_SEARCH_TIERED_MIN_CANDIDATES
  YAMS_SEARCH_TIERED_NARROW_VECTOR_SEARCH
  YAMS_SEARCH_TOPOLOGY_FINAL_RESCUE_SLOTS
  YAMS_SEARCH_TOPOLOGY_FUSION_RESCUE_SLOTS
  YAMS_SEARCH_VECTOR_ONLY_NEAR_MISS_PENALTY
  YAMS_SEARCH_VECTOR_ONLY_NEAR_MISS_RESERVE
  YAMS_SEARCH_VECTOR_ONLY_NEAR_MISS_SLACK
  YAMS_SEARCH_WEAK_QUERY_ENTITY_VECTOR_FANOUT_MULTIPLIER
  YAMS_SEARCH_WEAK_QUERY_MIN_TEXT_HITS
  YAMS_SEARCH_WEAK_QUERY_MIN_TOP_TEXT_SCORE

Declared behavior change: YAMS_SEARCH_RERANK_TOP_K and
YAMS_SEARCH_SEMANTIC_RESCUE_MIN_SCORE were older spellings of
YAMS_SEARCH_RERANK_TOPK and YAMS_SEARCH_SEMANTIC_RESCUE_MIN_VECTOR_SCORE
(different clamps, later block won when both were set); only the
current spellings remain. YAMS_SEARCH_SEMANTIC_RESCUE_SLOTS was read by
two identical blocks and is now read once.

A test builds the environment over a recording lookup and asserts none
of the retired names is ever consulted, and that the surviving names
are consulted exactly once. production_environment_keys.txt shrinks by
45 (432 -> 387); the bidirectional ratchet reports 0 new, 0 stale.

The search_latency_graph_rerank task in .vscode/tasks.json set two of the
retired overlays; those assignments are dropped so the task does not claim a
configuration the code no longer honours.

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

* refactor(config): drop unread embeddings.* keys and the no-op toggles

yams config embeddings enable/disable/tune wrote embeddings.auto_generate,
embeddings.generation_delay_ms, and embeddings.batch_size, and the
migrator seeded them (plus embeddings.auto_on_add) into every new
config.toml. No daemon code reads any of them: the post-ingest queue
always dispatches embed jobs when an embed queue exists, and the only
batch size the resolvers read is embeddings.runtime.batch_size. The
toggle was a switch wired to nothing, and yams status advised users to
flip it.

- embeddings enable and disable are removed. enable duplicated
  embeddings model <name> once its dead keys are gone; a kept no-op
  would be a shim. status no longer prints an auto-generation line and
  shows the runtime batch size when set. tune presets write
  embeddings.runtime.batch_size and drop the delay.
- config_migration no longer seeds auto_generate, auto_on_add,
  generation_delay_ms, or a top-level batch_size.
- ConfigResolver and the compatibility policy honour a legacy
  [embeddings] batch_size silently when the runtime key is absent, so
  configs in the wild get their value applied without a file rewrite (the
  migrator exits early for v3 configs, so a rewrite would never run).
- status and model hints point at embeddings model <name>.

Declared behavior change: `yams config embeddings enable|disable` are
unknown subcommands now.

Declared behavior change: the legacy [embeddings] batch_size was written by
`yams init` (32), `embeddings tune quality` (8) and `embeddings enable` (16)
but no resolver ever read it. Honouring it as a fallback applies those numbers
for the first time; the one consumer whose result moves is the doctor embedding
repair batch (embeddingPolicy.runtime.batchSize.value_or(8)), which becomes 32
on a stock config. The embedding service already defaulted to 32.

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

* feat(config): add [tuning] keys for the setters only env could reach

Seventeen TuneAdvisor setters were exercised by tests but had no TOML
key, so production could reach them only through a deprecated YAMS_*
overlay: connection slot sizing, the CPU-high threshold, the ONNX
concurrency and reservation knobs, model-eviction thresholds, ingest
worker cap, store/embed channel capacities, work-coordinator threads,
and connection lifetime. AGENTS.md says tuning lives in typed config;
these were half-migrated.

Each gets a [tuning] key resolved through ConfigResolver alongside the
existing ones, with provenance recorded, and each is included in
resetConfiguredOverrides() so a reload that drops a key reverts it
(the three with dedicated reset helpers call those). The environment
names keep working as compatibility inputs; nothing new is added to the
YAMS_* surface.

A table-driven test sets all 17 keys, checks every getter, then reloads
with an empty [tuning] section and checks every value reverted.
docs/architecture/environment-overrides.md lists the keys.

The ranged setters (cpu_high_pct 10..100, the three model-evict thresholds
in (0, 1), connection_lifetime_s at most 86400) keep their default when
handed a value outside the range. The resolver checks the same ranges first
and warns, so an ignored value is never recorded as config provenance; test
covers all three shapes.

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

* fix(config): report 0 for [tuning] integer keys instead of ignoring it

For the uint32 TuneAdvisor overrides 0 is the unset sentinel and below
every knob's minimum, so `pool_ipc_min = 0` used to be stored, read back
as "unset", and silently fall through to the default while the resolver
still recorded config provenance for it. applyUint32 now warns and skips
the value: nothing changes for the operator except that the mistake is
visible.

Two keys mean something by 0 and are exempt: post_ingest_threads (0 =
auto, which the config migrator seeds into every config and
`yams config` displays as "(auto)") and connection_lifetime_s (0 = no
recycling; its setter takes a signed sentinel and accepts 0, and the
environment spelling always did). Both keep their provenance and stay
silent, so a stock config produces no warning.

Test: pool_ipc_min = 0 and worker_poll_ms = 0 leave the defaults and
record no provenance, pool_ipc_max = 48 still applies, and the two
zero-valid keys apply with provenance.

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

* refactor(config): one embedding-runtime resolver, one tuning baseline

Two resolvers read the same five environment keys and three TOML keys
for the embedding runtime with different error semantics:
ConfigResolver::resolveEmbeddingConfig used the strict typed readers
(warn and keep the default), while resolveEmbeddingRuntimePolicy in
config_resolver_policies.cpp used std::stoull inside a bare catch, so
YAMS_EMBED_BATCH=12abc became 12 on one path and a rejected value on
the other. The compatibility entry point is now a projection of the
typed resolution onto the EmbeddingRuntimePolicy shape that library
callers (vector, repair) still consume; it lives in ConfigResolver.cpp
because DaemonConfig is declared there. 91 lines of duplicate parsing
go away.

yams doctor tuning carried its own [tuning] baseline table and it had
drifted: worker_poll_ms 75 against the daemon default of 150,
pool_io_max sized from hardware against a default of 32, so
`doctor tuning --apply` wrote defaults as divergent overrides. The
baseline now reads TuneAdvisor's effective values, which is what
"baseline" should mean.

Tests: the compatibility policy rejects 12abc and agrees with the typed
resolver; the doctor proposal equals TuneAdvisor for every key.

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

* refactor(config): stop writing the unread search.reranker_model_path

yams init wrote both search.reranker_model (the name the daemon resolves
through ConfigResolver::resolveRerankerModel) and
search.reranker_model_path, a derived on-disk path nothing in the
daemon, search, or vector code reads; yams config search reranker
status then echoed it back as if it mattered. init no longer writes the
path key and config no longer displays it. The branch that erases a
stale reranker_model_path line from an existing config is kept so old
files converge.

Of the three "aliased key clusters" flagged by the audit, this was the
only real drift: the three embedding-dimension keys are already one
centralized alias set in config_helpers.cpp (read any, write all), and
msl_stack_log_warn_bytes is a metrics counter name, not a config key.

portability_allowlist.txt: three init_command.cpp anchors reflowed; no
new environment reads.

The model command's post-download hint still told operators to set
search.reranker_model_path; that line goes too (the two lines above it
already name the commands that configure the reranker).

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

* fix(config): validate tuning ranges and pairs

Reject unsupported scalar and inverted paired limits before changing
runtime overrides or provenance. Preserve explicit zero ONNX reservations
with a distinct unset sentinel and avoid false default-backend conflicts.

Cover all 27 integer keys, inherited limits, and reservation reset.

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

---------

Signed-off-by: trvon <me@trevon.dev>
2026-09-12 10:09:19 -04:00
Trevon
e27d5e3e84
fix: Copilot review feedback and gitignore for artifacts (#26)
* feat: search work and moving to experimental

* WIP

* feat(search): diagnostic logging pipeline — graph build, concepts, reranker gate

- New [concepts] per-50-query log showing extracted query concepts, type
  distribution, and used_gliner flag.

- New [PIQ-entity] per-1000-dispatch + per-document completion log with
  entity type counts (e.g., 'protein=3, gene=1, chemical=2').

- New [graph_rerank-gate] one-shot log showing why enableGraphRerank
  is zeroed: shows shortQueryBudgeted, corpusWarming, bypassWarmingGate,
  lexicalReady, and post-ingest inflight.

- New [graph_rerank] per-50-query log with window size, matched
  candidates, applied count, concept count, and elapsed time.

- retrieval_quality_bench.cpp: add YAMS_SEARCH_BYPASS_CORPUS_WARMING_GATE=1
  so benchmark queries are not gated by freshness checks.

- resolve merge conflicts from experimental branch.

* fix(search): enable entity extraction for text files via GLiNER fallback

- prepareMetadataEntry: shouldDispatchEntity now also checks hasTitleExtractor()
  so plain-text files (.txt, .md) get entity extraction even when no binary
  entity provider supports their extension.

- processEntityExtractionStage: when no ExternalEntityProvider matches,
  fall back to processTitleExtractionStage which runs GLiNER on text.

- refreshStageAvailability: entity stage is now considered capable when
  hasTitleExtractor() is true, so the entity poller gets concurrency budget
  even if entityProviders_ is empty.

- kCombinedEntityTypes: add biomedical entity types (protein, gene, cell,
  disease, chemical, drug, pathway, biological_process, biomarker, anatomy,
  organism) so GLiNER extracts high-value biomedical entities instead of
  only generic NL types (person, organization, concept).

* perf(bench): add YAMS_POST_ENTITY_CONCURRENT=4 for text entity fallback throughput

* feat(search): fast token-based entity extraction for text documents

- Replace slow GLiNER-based entity extraction (~260ms/doc) with fast
  token-based concept mining (~1ms/doc) via generateFallbackQueryConcepts.
  Uses sub-phrase mining + IDF-weighted token salience — the same function
  already used for query-time concept fallback.

- Store entities with full KG scaffolding: KGNode with entity type/label,
  KGAlias for query-time resolution, DeferredEdge from entity→document,
  and DeferredDocEntity linking entity to document for getDocEntitiesForDocument.

- Add biomedical entity types to kCombinedEntityTypes in title extraction
  (protein, gene, cell, disease, chemical, drug, pathway, etc.) so GLiNER
  can output high-value biomedical entities when used.

- Add include for query_expansion.h to access generateFallbackQueryConcepts.

- bench: add YAMS_POST_ENTITY_CONCURRENT=4 for entity poller throughput.

Benchmark: 22K+ entities extracted across 5183 docs, ~41% high-value
biomedical. MRR 0.4281 (beats 0.4273 baseline by +0.2%).

* feat(diag): add firstDocEntities check to graph_rerank-gate log

- Queries kg_doc_entities for the first candidate document to verify
  whether fast entity writes were committed before queries start.
- Confirmed: firstDocEntities=0 — entities stuck in WriteCoordinator
  async queue when benchmark queries begin.

* fix(search): add periodic write-coordinator flush during entity extraction

Entity writes enqueued via writeCoordinator_ can accumulate since the
writer loop is capped at 8 batches/iteration. For 5K+ documents this
creates a backlog that outlasts the post-ingest drain wait — entities
are not committed to kg_doc_entities before benchmark queries start.

Add a periodic flush (every 128 batches, 500ms timeout) in the entity
extraction batch processor to drain the WC queue incrementally.

Diagnostic confirms firstDocEntities=0 persists — a synchronous
committed flush or batched WC enqueue is needed.

* fix(docker): add gfortran for openblas arm64 build

* fix(search): accumulate entity writes into shared WC batch, flush once

The WriteCoordinator writer loop is capped at 8 batches/iteration. With
5K+ per-doc entity writes, entities outlast the benchmark's post-ingest
drain and firstDocEntities=0 when the graph scorer runs.

- processEntityExtractionStage: add optional DeferredKGBatch* parameter.
  Text-fallback appends entity nodes/aliases/edges/doc-entities to the
  shared batch instead of creating per-doc WC batches.

- processEntityExtractionBatch: creates one DeferredKGBatch, passes it to
  all stage calls in the batch, enqueues to WC once at end.

- Single-shot WC flush: after all stages go idle (totalInFlight==0),
  calls writeCoordinator_->flush(15s) to drain remaining entity writes
  before benchmark queries start.

- DeferredKGBatch forward-declared in PostIngestQueue header.

* ci: fix free-disk-space action ref, sha didnt exist

* fix(search): revert WC accumulation, fix text fallback to per-doc writes

The shared-batch WC accumulation approach worked conceptually but:
- WC flush with totalInFlight==0 fires too early (before last batch)
- generateFallbackQueryConcepts produces empty concepts for 99% of
  document texts (designed for short queries, not abstracts)
- Only 1/5183 docs produced concepts → 1 doc worth of entities in KG

Revert to simple per-doc entity extraction. The enable=/disable=
graph reranker gate is still controlled by shortQueryBudgeted=1
which zeroes the graph reranker on the first query (intent=Code).

firstDocEntities=0 persists — entities need a different creation
strategy for document text (phrase mining too conservative).

* fix(docker): add curl retry for Zig download

* feat(search): per-profile ConceptExtractionBackend (Fallback vs GlinerWithFallback)

- search_engine_config.h: new ConceptExtractionBackend enum with Fallback
  (sub-phrase mining + IDF tokens, <1ms) and GlinerWithFallback (GLiNER
  first, fall back on empty/timeout). Default: GlinerWithFallback.

- search_tuner.h: SCIENTIFIC profile sets Fallback (GLiNER returns empty
  for 99% of short biomedical claims). Other profiles keep default.
  Wired through TunedParams.applyTo().

- search_engine.cpp: gate GLiNER concept extraction on the config backend.
  When Fallback, conceptFuture is never created and concepts come directly
  from generateFallbackQueryConcepts. Added [concept-backend] diagnostic.

- search_engine_builder.cpp: builder log now includes concept_backend
  in the override-state startup message.

- search_tuner_catch2_test.cpp: verify SCIENTIFIC profile uses Fallback.

Note: builder correctly sets Fallback but query-time workingConfig still
shows GlinerWithFallback (int=1). This is a config-sync issue between
builder-time profile application and runtime config snapshot — the
tuner or a post-override config copy may reset the field. To be fixed.

* refactor(search): extract concept resolver, per-profile backend, clean dead code

- New concept_resolver.h/cpp: extract enrichWithFallbackConcepts from the
  search engine monolith into a testable unit. Generates IDF-weighted
  token concepts via generateFallbackQueryConcepts, deduplicates, and
  appends to existing concepts.

- search_engine_config.h: new ConceptExtractionBackend enum (Fallback vs
  GlinerWithFallback). SCIENTIFIC profile sets Fallback since GLiNER
  extracts 0 concepts for 99% of short biomedical claims.

- search_tuner.h: wire conceptExtractionBackend through TunedParams,
  applyTo, seedTunedParamsFromConfig (the one-line fix that resolved
  the config-sync bug where profile Fallback was overridden at query
  policy resolution time).

- search_engine.cpp: materializeConcepts lambda restructured to always
  reach the fallback even when GLiNER future is invalid. Removed
  ~80 lines of diagnostic bloat ([concept-backend], [workingConfig-*],
  per-50 [concepts]). GLiNER gate checks config backend.

- PostIngestQueue.cpp: removed dead fast-token entity extraction
  (~150 lines of concept generation + KG scaffolding that produced
  0 entities for 99% of documents). Reverted entity-stage gating
  (entityCapable || hasTitleExtractor) and shouldDispatchEntity to
  extension-only checks. Removed DeferredKGBatch forward decl.

- gliner_query_extractor: removed unused createGlinerExtractionFunc-
  FromProvider fallback factory (~150 lines).

- ServiceManager.cpp: removed fallback call site for removed factory.

- builder log: removed concept_backend diagnostic line noise.

- search_tuner_catch2_test.cpp: verify SCIENTIFIC uses Fallback.

Net: ~400 lines removed, ~120 lines added (concept_resolver unit +
config wiring). GLiNER concept extraction savings: ~30-80ms/query
× 300 queries = 9-24s total for SCIENTIFIC profiles.

* fix: entity stage only for binaries, title stage for text

entity stage = binary providers (Ghidra/Zyp). title stage = GLiNER for all
text. No overlap — title already stores NL entities to KG.

* fix(docker): add wget for Zig, disable faiss

openblas arm64 build fails in Docker containers. YAMS_DISABLE_FAISS=1
env var skips faiss (and its openblas transitive dep). Zig download
now uses wget -c for resume on flaky ziglang.org connections.

* ci: add experimental branch to tests trigger

* ci: pin free-disk-space to v1.3.1

* feat: Simeon concept mining entity export for graph reranker

- simeon_lexical_backend.h: EntityCallback in Config. Called with
  (docId, entityText, confidence) per concept match per doc.

- simeon_lexical_backend.cpp: after mine_concepts, iterate docs
  via collect_doc_concepts + entity_callback.

- SearchEngineManager.cpp: enable concept_mining_enabled, wire
  entity_callback batch-inserting DocEntity via KG store. Fix
  kgStore capture-before-move race.

Note: simeon submodule has collect_doc_concepts in concept_mining.hpp
+ concept_mining.cpp (must commit to submodule separately).

* ci: disable faiss in warm and test jobs

* ci(bench): add faiss disable, ccache, and failure diagnostics to weekly benchmarks

* fix(metadata): retry constraint failures in executeQueryOnPool

FK race on Linux causes transient constraint failures when metadata
write races ahead of document commit. Previously treated as terminal.
Now retried with backoff like lock errors.

* fix(metadata): deduplicate batch entries before UPSERT

Duplicate (document_id, key) pairs within a single batch cause SQLite
ON CONFLICT DO UPDATE to fail with constraint violation. Dedup keeps
the last write per key.

* chore: bump simeon, add extraction readiness stats

Simeon: 8bf225e -> 6320ab6 (adapter + QPP router framework).
CorpusStats: add contentExtracted*, ftsIndexed*, titleCoverage,
languageCoverage, and KG topology richness fields.

* feat(search): integrate simeon EntropyRouter strategy lane, corpus-state tuning

- Wire EntropyRouter + Keyphrase/LeadField strategies into SimeonLexicalBackend
- Add scoreStrategyRouted(), hasStrategyRouter(), strategy_router_enabled config
- Add YAMS_SIMEON_STRATEGY_ROUTER_ENABLED env wiring
- Add applyCorpusStateAdjustments(): per-corpus-state recall push (vec max,
  rescue slots, weak-query fanout, entity vec expansion, NER damping)
- Extend CorpusStats with extraction/FTS/title/language/KG edge+alias density
- Add hasRichGraphTopology(), nerOnlyNoEdges damping to graph adjustments
- Add 14 new engine-policy benchmark candidates (retrieval lanes, RRF sweep,
  aggressive recall, strategy router)
- Weight miss_pre_fusion_rate in optimization objective (0.25x)
- Add Simeon lexical concept/doc count to IndexFreshnessSnapshot + status
- Bump simeon submodule (retrieval_strategy + corpus_adapter API)

* feat(search): add concept_count and concept_mining_enabled accessors

* feat(search): add ScientificAdapter + RM3 PRF blend

ScientificAdapter: training-free entity extraction for scientific
text via regex/suffix patterns (biomedical suffixes, ALL_CAPS symbols,
capitalized multi-word terms, measurements). Replaces TextAdapter
in strategy router build, providing entity lists for KeyphraseStrategy.

RM3: add score_with_prf blend path to scoreStrategyRouted at 0.30
weight when rm3_enabled=true. New benchmark candidate
scientific_strategy_rm3.

Strategy router + ScientificAdapter: mrr=0.4514 ndcg=0.4789 recall=0.5849

* docs: soften governance and contribution prose

Replace prescriptive language ('must', 'require', 'adjudicates') with
friendlier, more welcoming phrasing across governance docs, PR template,
security policy, and contributing guide.

* feat(extract): add language-agnostic IMRAD section detection, expand entity types

detectDocumentSections(): structural heuristics for title/abstract/body
using line-length, ALL_CAPS, numbering patterns. No word matching.
Works across all languages and scripts.

deriveTitle(): add IMRAD detection step before first-line fallback.
isHighValueGraphType(): use ScientificAdapter suffix detection (40+
biomedical suffixes) instead of hardcoded 11 types.

* feat(ingest): field-weighted FTS5, IMRAD claim segmentation, ScientificAdapter fallback

- FTS5: title tokens repeated 3x, abstract 2x, body 1x in content
  field for BM25 field weighting without schema migration
- IMRAD-aware claim segmentation: buildBodyClaimSegments splits
  each detected section independently, distributes maxSegments
- ScientificAdapter fallback: when GLiNER unavailable, inline
  entity extraction via suffix/pattern detection → direct KG write
- Add abstract field to PreparedMetadataEntry + BatchContentEntry

* refactor(daemon): extract enrichment stages to post_ingest_enrichment.cpp

Split PostIngestQueue.cpp (3145 lines) into:
- PostIngestQueue.cpp (~3084 lines): coordinator, lifecycle, queue
  management, extraction pipeline, gradient limiters
- post_ingest_enrichment.cpp (new, 701 lines): KG/symbol/entity/title
  stage processing with self-contained enrichment utilities

* fix(daemon): restore enrichment utilities to PostIngestQueue.cpp

Processing methods still in PostIngestQueue.cpp reference entity/NL
utilities (isUsefulNlEntity, buildBodyClaimSegments, etc.) that were
removed during decomposition. Restore them to anonymous namespace.

* fix: address PR #25 Copilot review feedback

- Add missing #include <unordered_map> to concept_resolver.cpp
- Batch entity writes per doc in SearchEngineManager (reduces write amp)
- Remove non-existent CorpusAdapter API claims from README
- Replace absolute paths with repo-relative in daemon-download-jobs.md
- Revert plugin-zyp default to false (noisy warnings)
- Fix grammar in extraction-repair-pipeline.md heading
- Add gitignore entries for .wrangler, .claude, .artifacts, papers

* fix: Copilot feedback - IDF passthrough, batch flush, debug gate, IMRAD comment

- Pass IDF map through enrichWithFallbackConcepts for weighted fallback
- Batch entity writes per doc with threshold flush in SearchEngineManager
- Downgrade graph_rerank-gate diagnostic to spdlog::debug
- Add TODO for entity_callback wiring during concept mining
- Fix DocumentSections comment to match language-agnostic implementation

* chore: bump simeon (ScientificAdapter v3)

* fix: resolve merge conflict markers, add missing <random> include

Remove leftover <<<<<<< / ======= / >>>>>>> from earlier merge.
Add #include <random> to ingestion_throughput_bench.cpp.

* chore: trigger CI after simeon submodule push
2026-05-08 05:29:46 -04:00
Trevon
72647bbaf7
chore: stabilize CI, faiss, metadata, docker, and simeon (#25)
- CI warm: ccache dep, continue-on-error, 60min timeout, YAMS_DISABLE_FAISS
- Faiss: YAMS_HAS_FAISS guard, Apple Clang disable, OpenMP detection
- Metadata: retry constraint failures, deduplicate batch UPSERT entries
- Docker: wget for Zig, gfortran, YAMS_DISABLE_FAISS=1
- CI config: free-disk-space v1.3.1, libomp-18-dev, experimental trigger
- Weekly benchmarks: faiss disable, ccache, diagnostics capture
- Simeon: bump to 7763a97, EntropyRouter, concept_count
- CorpusStats: extraction readiness fields
- Remove committed artifacts (.wrangler, .artifacts, dispatcher_external)
- Fix .vscode/settings.json hardcoded path

Signed-off-by: trvon <git@trevon.dev>
2026-05-07 21:07:59 -04:00
trvon
285c6f7607
Revert "Experimental Merge (#23)"
This reverts commit e21de6ff4a.
2026-05-07 20:44:33 -04:00
Trevon
e21de6ff4a
Experimental Merge (#23)
* feat: search work and moving to experimental

* WIP

* feat(search): diagnostic logging pipeline — graph build, concepts, reranker gate

- New [concepts] per-50-query log showing extracted query concepts, type
  distribution, and used_gliner flag.

- New [PIQ-entity] per-1000-dispatch + per-document completion log with
  entity type counts (e.g., 'protein=3, gene=1, chemical=2').

- New [graph_rerank-gate] one-shot log showing why enableGraphRerank
  is zeroed: shows shortQueryBudgeted, corpusWarming, bypassWarmingGate,
  lexicalReady, and post-ingest inflight.

- New [graph_rerank] per-50-query log with window size, matched
  candidates, applied count, concept count, and elapsed time.

- retrieval_quality_bench.cpp: add YAMS_SEARCH_BYPASS_CORPUS_WARMING_GATE=1
  so benchmark queries are not gated by freshness checks.

- resolve merge conflicts from experimental branch.

* fix(search): enable entity extraction for text files via GLiNER fallback

- prepareMetadataEntry: shouldDispatchEntity now also checks hasTitleExtractor()
  so plain-text files (.txt, .md) get entity extraction even when no binary
  entity provider supports their extension.

- processEntityExtractionStage: when no ExternalEntityProvider matches,
  fall back to processTitleExtractionStage which runs GLiNER on text.

- refreshStageAvailability: entity stage is now considered capable when
  hasTitleExtractor() is true, so the entity poller gets concurrency budget
  even if entityProviders_ is empty.

- kCombinedEntityTypes: add biomedical entity types (protein, gene, cell,
  disease, chemical, drug, pathway, biological_process, biomarker, anatomy,
  organism) so GLiNER extracts high-value biomedical entities instead of
  only generic NL types (person, organization, concept).

* perf(bench): add YAMS_POST_ENTITY_CONCURRENT=4 for text entity fallback throughput

* feat(search): fast token-based entity extraction for text documents

- Replace slow GLiNER-based entity extraction (~260ms/doc) with fast
  token-based concept mining (~1ms/doc) via generateFallbackQueryConcepts.
  Uses sub-phrase mining + IDF-weighted token salience — the same function
  already used for query-time concept fallback.

- Store entities with full KG scaffolding: KGNode with entity type/label,
  KGAlias for query-time resolution, DeferredEdge from entity→document,
  and DeferredDocEntity linking entity to document for getDocEntitiesForDocument.

- Add biomedical entity types to kCombinedEntityTypes in title extraction
  (protein, gene, cell, disease, chemical, drug, pathway, etc.) so GLiNER
  can output high-value biomedical entities when used.

- Add include for query_expansion.h to access generateFallbackQueryConcepts.

- bench: add YAMS_POST_ENTITY_CONCURRENT=4 for entity poller throughput.

Benchmark: 22K+ entities extracted across 5183 docs, ~41% high-value
biomedical. MRR 0.4281 (beats 0.4273 baseline by +0.2%).

* feat(diag): add firstDocEntities check to graph_rerank-gate log

- Queries kg_doc_entities for the first candidate document to verify
  whether fast entity writes were committed before queries start.
- Confirmed: firstDocEntities=0 — entities stuck in WriteCoordinator
  async queue when benchmark queries begin.

* fix(search): add periodic write-coordinator flush during entity extraction

Entity writes enqueued via writeCoordinator_ can accumulate since the
writer loop is capped at 8 batches/iteration. For 5K+ documents this
creates a backlog that outlasts the post-ingest drain wait — entities
are not committed to kg_doc_entities before benchmark queries start.

Add a periodic flush (every 128 batches, 500ms timeout) in the entity
extraction batch processor to drain the WC queue incrementally.

Diagnostic confirms firstDocEntities=0 persists — a synchronous
committed flush or batched WC enqueue is needed.

* fix(docker): add gfortran for openblas arm64 build

* fix(search): accumulate entity writes into shared WC batch, flush once

The WriteCoordinator writer loop is capped at 8 batches/iteration. With
5K+ per-doc entity writes, entities outlast the benchmark's post-ingest
drain and firstDocEntities=0 when the graph scorer runs.

- processEntityExtractionStage: add optional DeferredKGBatch* parameter.
  Text-fallback appends entity nodes/aliases/edges/doc-entities to the
  shared batch instead of creating per-doc WC batches.

- processEntityExtractionBatch: creates one DeferredKGBatch, passes it to
  all stage calls in the batch, enqueues to WC once at end.

- Single-shot WC flush: after all stages go idle (totalInFlight==0),
  calls writeCoordinator_->flush(15s) to drain remaining entity writes
  before benchmark queries start.

- DeferredKGBatch forward-declared in PostIngestQueue header.

* ci: fix free-disk-space action ref, sha didnt exist

* fix(search): revert WC accumulation, fix text fallback to per-doc writes

The shared-batch WC accumulation approach worked conceptually but:
- WC flush with totalInFlight==0 fires too early (before last batch)
- generateFallbackQueryConcepts produces empty concepts for 99% of
  document texts (designed for short queries, not abstracts)
- Only 1/5183 docs produced concepts → 1 doc worth of entities in KG

Revert to simple per-doc entity extraction. The enable=/disable=
graph reranker gate is still controlled by shortQueryBudgeted=1
which zeroes the graph reranker on the first query (intent=Code).

firstDocEntities=0 persists — entities need a different creation
strategy for document text (phrase mining too conservative).

* fix(docker): add curl retry for Zig download

* feat(search): per-profile ConceptExtractionBackend (Fallback vs GlinerWithFallback)

- search_engine_config.h: new ConceptExtractionBackend enum with Fallback
  (sub-phrase mining + IDF tokens, <1ms) and GlinerWithFallback (GLiNER
  first, fall back on empty/timeout). Default: GlinerWithFallback.

- search_tuner.h: SCIENTIFIC profile sets Fallback (GLiNER returns empty
  for 99% of short biomedical claims). Other profiles keep default.
  Wired through TunedParams.applyTo().

- search_engine.cpp: gate GLiNER concept extraction on the config backend.
  When Fallback, conceptFuture is never created and concepts come directly
  from generateFallbackQueryConcepts. Added [concept-backend] diagnostic.

- search_engine_builder.cpp: builder log now includes concept_backend
  in the override-state startup message.

- search_tuner_catch2_test.cpp: verify SCIENTIFIC profile uses Fallback.

Note: builder correctly sets Fallback but query-time workingConfig still
shows GlinerWithFallback (int=1). This is a config-sync issue between
builder-time profile application and runtime config snapshot — the
tuner or a post-override config copy may reset the field. To be fixed.

* refactor(search): extract concept resolver, per-profile backend, clean dead code

- New concept_resolver.h/cpp: extract enrichWithFallbackConcepts from the
  search engine monolith into a testable unit. Generates IDF-weighted
  token concepts via generateFallbackQueryConcepts, deduplicates, and
  appends to existing concepts.

- search_engine_config.h: new ConceptExtractionBackend enum (Fallback vs
  GlinerWithFallback). SCIENTIFIC profile sets Fallback since GLiNER
  extracts 0 concepts for 99% of short biomedical claims.

- search_tuner.h: wire conceptExtractionBackend through TunedParams,
  applyTo, seedTunedParamsFromConfig (the one-line fix that resolved
  the config-sync bug where profile Fallback was overridden at query
  policy resolution time).

- search_engine.cpp: materializeConcepts lambda restructured to always
  reach the fallback even when GLiNER future is invalid. Removed
  ~80 lines of diagnostic bloat ([concept-backend], [workingConfig-*],
  per-50 [concepts]). GLiNER gate checks config backend.

- PostIngestQueue.cpp: removed dead fast-token entity extraction
  (~150 lines of concept generation + KG scaffolding that produced
  0 entities for 99% of documents). Reverted entity-stage gating
  (entityCapable || hasTitleExtractor) and shouldDispatchEntity to
  extension-only checks. Removed DeferredKGBatch forward decl.

- gliner_query_extractor: removed unused createGlinerExtractionFunc-
  FromProvider fallback factory (~150 lines).

- ServiceManager.cpp: removed fallback call site for removed factory.

- builder log: removed concept_backend diagnostic line noise.

- search_tuner_catch2_test.cpp: verify SCIENTIFIC uses Fallback.

Net: ~400 lines removed, ~120 lines added (concept_resolver unit +
config wiring). GLiNER concept extraction savings: ~30-80ms/query
× 300 queries = 9-24s total for SCIENTIFIC profiles.

* fix: entity stage only for binaries, title stage for text

entity stage = binary providers (Ghidra/Zyp). title stage = GLiNER for all
text. No overlap — title already stores NL entities to KG.

* fix(docker): add wget for Zig, disable faiss

openblas arm64 build fails in Docker containers. YAMS_DISABLE_FAISS=1
env var skips faiss (and its openblas transitive dep). Zig download
now uses wget -c for resume on flaky ziglang.org connections.

* ci: add experimental branch to tests trigger

* ci: pin free-disk-space to v1.3.1

* feat: Simeon concept mining entity export for graph reranker

- simeon_lexical_backend.h: EntityCallback in Config. Called with
  (docId, entityText, confidence) per concept match per doc.

- simeon_lexical_backend.cpp: after mine_concepts, iterate docs
  via collect_doc_concepts + entity_callback.

- SearchEngineManager.cpp: enable concept_mining_enabled, wire
  entity_callback batch-inserting DocEntity via KG store. Fix
  kgStore capture-before-move race.

Note: simeon submodule has collect_doc_concepts in concept_mining.hpp
+ concept_mining.cpp (must commit to submodule separately).

* ci: disable faiss in warm and test jobs

* ci(bench): add faiss disable, ccache, and failure diagnostics to weekly benchmarks

* fix(metadata): retry constraint failures in executeQueryOnPool

FK race on Linux causes transient constraint failures when metadata
write races ahead of document commit. Previously treated as terminal.
Now retried with backoff like lock errors.

* fix(metadata): deduplicate batch entries before UPSERT

Duplicate (document_id, key) pairs within a single batch cause SQLite
ON CONFLICT DO UPDATE to fail with constraint violation. Dedup keeps
the last write per key.

* chore: bump simeon, add extraction readiness stats

Simeon: 8bf225e -> 6320ab6 (adapter + QPP router framework).
CorpusStats: add contentExtracted*, ftsIndexed*, titleCoverage,
languageCoverage, and KG topology richness fields.

* feat(search): integrate simeon EntropyRouter strategy lane, corpus-state tuning

- Wire EntropyRouter + Keyphrase/LeadField strategies into SimeonLexicalBackend
- Add scoreStrategyRouted(), hasStrategyRouter(), strategy_router_enabled config
- Add YAMS_SIMEON_STRATEGY_ROUTER_ENABLED env wiring
- Add applyCorpusStateAdjustments(): per-corpus-state recall push (vec max,
  rescue slots, weak-query fanout, entity vec expansion, NER damping)
- Extend CorpusStats with extraction/FTS/title/language/KG edge+alias density
- Add hasRichGraphTopology(), nerOnlyNoEdges damping to graph adjustments
- Add 14 new engine-policy benchmark candidates (retrieval lanes, RRF sweep,
  aggressive recall, strategy router)
- Weight miss_pre_fusion_rate in optimization objective (0.25x)
- Add Simeon lexical concept/doc count to IndexFreshnessSnapshot + status
- Bump simeon submodule (retrieval_strategy + corpus_adapter API)

* feat(search): add concept_count and concept_mining_enabled accessors

* feat(search): add ScientificAdapter + RM3 PRF blend

ScientificAdapter: training-free entity extraction for scientific
text via regex/suffix patterns (biomedical suffixes, ALL_CAPS symbols,
capitalized multi-word terms, measurements). Replaces TextAdapter
in strategy router build, providing entity lists for KeyphraseStrategy.

RM3: add score_with_prf blend path to scoreStrategyRouted at 0.30
weight when rm3_enabled=true. New benchmark candidate
scientific_strategy_rm3.

Strategy router + ScientificAdapter: mrr=0.4514 ndcg=0.4789 recall=0.5849
2026-05-07 20:36:10 -04:00
trvon
fc284f3b37
fix: resolving TSAN issues and expanding graph building to use gliner data 2026-02-19 14:52:01 -05:00
trvon
c7c5b63317
feat: adding adidtional tasks 2026-02-19 10:54:13 -05:00
trvon
207532f46a
merge: integrate main into experimental (preserve PBI-081 simplification)
Merge main's 93 commits into experimental, preserving architectural updates
decisions:

- Keep ResourceGovernor as centralized pool registry (experimental's PBI-081 Phase 2)
- Translate all PoolManager API calls to ResourceGovernor equivalents
- Remove PoolManager.{h,cpp} from build (absorbed into ResourceGovernor)
- Preserve main's enhancements: RepairService, IOCoordinator, GradientLimiter,
  embed_preparer, GPU info, plugin trust, 60+ new test files
- Take main's version for 28 of 31 conflicts (more comprehensive rewrites)
- Keep experimental's ResourceGovernor.h (expanded pool API)
- Manual merge for .vscode/settings.json (use workspace-relative paths)
2026-02-19 10:01:01 -05:00
trvon
c973a24ff5
feat: merge vscode settings 2026-02-17 19:16:39 -05:00
trvon
8f38ee76be
feat: updating metrics for search and retrieval for future learning system. Additional tuning for search performance 2026-02-13 21:09:26 -05:00
trvon
44a94eabe1
feat: fuzzing and config expansion. Moving to optimizing ingestion. Adding tunable embedding (chunk size etc.) 2026-02-11 23:21:26 -05:00
trvon
82eea28210
removing duplicate hnsw and leverage sqlite vec cpp library updates 2026-01-05 10:16:32 -05:00
trvon
6c6e7b9693
Merge branch 'main' of github.com:trvon/yams 2025-12-03 14:11:05 -05:00
trevon
7fe8721c5b
daemon worker coordinator race condition fix for windows 2025-11-25 20:11:06 -05:00
trevon
2a3f5be870
Merge branch 'main' of https://github.com/trvon/yams 2025-11-25 13:18:24 -05:00
trevon
eb7e9c27e2
windows build running. resolving plugin loading 2025-11-25 09:56:50 -05:00
trvon
41bb390be9
hot fix v0.7.9 2025-11-15 11:02:30 -05:00
trvon
c1d6a992fc
feat(search): implement parallel post-processing (PBI-001 Phase 3)
Parallel Post-Processor with Threshold-Based Activation
--------------------------------------------------------
- New ParallelPostProcessor class (120 lines header, 247 lines impl)
- Uses std::async for concurrent facet/highlight/snippet generation
- Threshold = 100 results (sequential below, parallel at/above)
- Facets now operate on filtered results (fixed data flow bug)

Performance Results (100 iterations)
------------------------------------
- 100 results: 0.06ms (~1.66M ops/sec) - sequential path
- 500 results: 0.23ms (~2.21M ops/sec) - parallel path
- 1000 results: 0.43ms (~2.32M ops/sec) - parallel path
- Speedup: ~3.4x faster at 1000 results

Test Coverage
-------------
- 5 unit tests (threshold behavior, facets, snippets, edge cases)
- All tests passing (5/5 ✅)
- 3 benchmarks added to search_benchmarks.cpp

Files Changed
-------------
- include/yams/search/parallel_post_processor.hpp (NEW)
- src/search/parallel_post_processor.cpp (NEW)
- src/search/search_executor.cpp (integrated)
- tests/unit/search/search_executor_test.cpp (+6 tests)
- tests/benchmarks/search_benchmarks.cpp (+3 benchmarks)
- CHANGELOG.md (documented with measured results)
- docs/delivery/001/prd.md (Phase 3 → ✅ COMPLETED)

Technical Details
-----------------
- Parallel path: filtering → parallel(facets + highlights) → wait
- Sequential path: identical logic, no std::async overhead
- Correctness preserved: identical output to previous sequential impl
- Build: 46/46 targets compiling successfully
2025-11-09 08:04:15 -05:00
trvon
bbf23bb190
test migrations to catch2, service manager + socket server refactor for better startup performance. search bug fixes 2025-10-29 23:08:09 -04:00
trvon
6971daf41c
staging docs 2025-10-23 23:01:29 -04:00
trvon
692dabe16e
commititing readme and vscode settings fixes 2025-10-20 16:14:57 -04:00
trvon
b6ca31dfb0
adding symbol extraction work, simplying build with ./setup.sh, updated plugin tests with new meson shard and other goodies 2025-10-20 16:11:31 -04:00
trvon
4a894911da
testing fixings for ubuntu and grep / search improvements 2025-10-12 08:03:58 -04:00
trvon
5bb124a3c1
v0.7.3 2025-10-08 17:02:37 -04:00
trvon
e586892e06
checkpoint. Expanded tests and resolved minor issues with grep, ci/cd and daemon protocol add spec 2025-09-29 14:38:04 -04:00
Trevon
5fd0db37eb
test updates and prompt improvements for codex 2025-09-27 21:40:47 -04:00
Trevon
19fb4fee75
updating, stagging fixes, then will address ci 2025-09-27 04:39:58 -04:00
Trevon
463bd9c367
test improvements, search bug fixes, sourcehut build patches 2025-09-24 11:33:55 -04:00
Trevon
43699f99a3
v0.7.0-prerelease 2025-09-20 22:55:34 -04:00
Trevon
31e1aa5b56
v0.6.14 2025-09-12 23:37:14 -04:00
Trevon
956c43b80b
v0.6.12 experiemental 2025-09-11 11:28:42 -04:00
Trevon
abdbd68e06
build system improvements, clang-tidy integration for warnings equals errors (need to continue). POSIX socket legacy code removal 2025-09-03 13:22:30 -04:00
Trevon
34679f0d2a
v0.6.0 staging (recreating branch) 2025-09-01 07:50:02 -04:00
Trevon
7f821a4b22
cleaning up for release 2025-08-31 21:45:43 -04:00
trevon
d285b19b55 Resolve merge conflict after revert; keep local daemon_command.cpp changes 2025-08-31 17:27:46 -04:00
Trevon
906d25b249
Checkpoint from VS Code for coding agent session 2025-08-30 19:52:24 -04:00
Trevon
7c92f09d21
v0.5.7 2025-08-29 06:12:50 -04:00