Skip to content

feat(brain): harden RAG index for bot consumption - #38

Merged
alexk-dev merged 10 commits into
mainfrom
feature/rag-hardening
Apr 19, 2026
Merged

feat(brain): harden RAG index for bot consumption#38
alexk-dev merged 10 commits into
mainfrom
feature/rag-hardening

Conversation

@alexk-dev

@alexk-dev alexk-dev commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary

Hardens golemcore-brain as a retrieval and integration backend: one public search API, explicit reindex operations, safer embedding-index lifecycle, broader automated coverage, and stricter quality gates copied from golemcore-bot without enabling Sonar.

What Changed

  • Replaced split search endpoints with the unified POST /api/spaces/{slug}/search contract.
  • Supported search modes are now auto, fts, and hybrid; removed the old semantic and lexical aliases so clients use explicit mode names.
  • Added admin reindex namespace endpoints:
    • POST /api/admin/spaces/{slug}/reindex
    • POST /api/admin/spaces/reindex
  • Added UI controls for per-space reindex and full reindex on the Spaces page.
  • Hardened indexing around embedding model changes, stale/mixed embedding vectors, incomplete embedding batches, title-prefixed chunk embedding input, multi-chunk storage, and hybrid RRF fusion.
  • Ensured write paths keep indexes current for page edits, API writes, and Markdown archive imports.
  • Added coalescing for scheduled full rebuilds so repeated reindex requests collapse into one queued run plus one follow-up when needed.
  • Added JaCoCo reporting and Codecov upload wiring, plus strict PMD/SpotBugs/formatter configuration aligned with golemcore-bot. Sonar is intentionally not enabled in this PR.
  • Added Javadocs and inline docs for public integration DTOs/controllers and the non-obvious indexing logic.
  • Documented the public integration API in README.md as a table, excluding internal LLM/user-management APIs.

Test Coverage

  • Unit coverage for search mode parsing, alias rejection, hybrid fallback, embedding readiness, model mismatch handling, partial vectors, chunking, RRF fusion, scheduled rebuild coalescing, and executor rejection recovery.
  • Adapter contract coverage for SQLite and in-memory embedding indexes, including multi-chunk documents and stored model-id consistency.
  • Integration coverage for public search API validation, space isolation, API-key boundaries, reindex namespace behavior, Markdown archive import indexing, UI/API page updates, public read-only access, history, conflicts, and chat/Dynamic API flows.
  • Frontend tests cover unified search requests and reindex buttons.

alexk-dev and others added 10 commits April 15, 2026 15:21
Fix ten RAG-quality issues flagged during senior AI engineering review
so golemcore-brain is safe to use as the retrieval backend for the bot.

- Track stored embedding model id and force a full rebuild when the
  configured model changes; gate `embeddingsReady` on model match so
  callers see "not ready" instead of mixed-model vectors.
- Guard cosine similarity against dimension mismatches in both SQLite
  and in-memory adapters — fail loudly instead of returning garbage.
- Rewrite chunking to pack whole paragraphs under a 2500/300 budget
  with char-slice fallback for overlong paragraphs.
- Prepend document title to every chunk's embed input while keeping
  raw chunk text in the stored excerpt.
- Fuse dense and lexical hits via reciprocal rank fusion (k=60) in
  `semanticSearch`, with 2x overfetch to leave a rerank seam.
- Make the search limit caller-controlled, resolve the embedding
  model once per sync, and keep partial embed-batch results instead
  of dropping the whole change set on a short response.
- Document the single-thread indexing executor contract on
  `scheduleSynchronize`.

Covered by TDD red→green cycles; full suite green (92 tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds page patch/tx operations, graph endpoints, access tracking with
orphan-GC, and frontend user menu refinements. Extends test coverage
for the new WikiApplicationService and filesystem access-stats adapter.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Collapse switch-assign into switch-expression for patch reason
- Drop unused imports/local in WikiControllerTxTest
- Rename MutableClock.instant field to avoid method-name collision
- Use try-with-resources for ExecutorService and narrow catch to Exception

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alexk-dev
alexk-dev merged commit 51767e0 into main Apr 19, 2026
13 checks passed
@alexk-dev
alexk-dev deleted the feature/rag-hardening branch April 19, 2026 15:36
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