Skip to content

feat(core): improve indexing recovery and scoped retrieval for v4.10.0 - #234

Merged
lyonzin merged 23 commits into
masterfrom
perf/memory-gpu-audit
Oct 4, 2026
Merged

lyonzin merged 23 commits into
masterfrom
perf/memory-gpu-audit

Conversation

@lyonzin

@lyonzin lyonzin commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prepare 4.10.0 with bounded memory, safer indexing and rollback, recursive folder filters before retrieval top-k, and better semantic candidate coverage. Repeated indexing previously retained historical state, could duplicate derived rows or lose recoverable state after failures, and could select the wrong root in a Windows preflight subprocess.

Fixes #223, fixes #224, fixes #232, fixes #233.

This candidate incorporates PR #225 and the reviewed contributions from #222, #226 and #227–231. PR #226 includes all four commits through 4571e3e; dependency changes run through the combined CI rather than relying on their older isolated checks. The unpublished 4.9.3 proposal is included in 4.10.0.

Type of change

  • feat — recursive include/exclude folder filters; explicit Windows DirectML
  • fix — indexing, rollback, cache, parser and process lifecycle correctness
  • perf — bounded retention, selective incremental work and indexed FTS5 updates
  • test — real storage, concurrency, failure, packaging and platform regressions
  • chore — dependency updates, release publication and measurement gates
  • BREAKING CHANGE

What changed

  • Aggregate metric observations, pool repeated BM25 tokens per index and avoid retaining historical mutation payloads before lexical initialization.
  • Discover files before parsing, bound pending indexing work, validate vectors and source containment, and preserve source versions captured before parsing.
  • Make FTS5 replay idempotent, batch candidate hydration and keep migration count/stream/publication in one source snapshot.
  • Preserve recoverable collections during publication/startup, including TTL cleanup tied to the committed replacement collection UUID.
  • Preserve logical filenames for staged Dockerfile/Makefile/Tiltfile writes and invalidate cache generations after failed mutations and rollback.
  • Restore document inventory before vector rollback and persist a bounded, collection-bound repair journal when rollback itself fails. The next incremental run repairs only the affected source, including after restart; journal cleanup follows the metadata commit.
  • Apply include_folders/exclude_folders before top-k across Chroma/BM25/FTS5, intersect with category, and include scope in cache identity.
  • Separate the internal semantic pool from the configured public output cap and retain candidates from both channels within the existing bounded reranker budget. Explicit alpha 0/1 remains single-channel.
  • Use actual embedding providers for batch sizing: CPU defaults to 32, CUDA to 256, and explicit DirectML to 8. Serialize DirectML calls and require an adapter index; automatic GPU selection remains CUDA/CPU.
  • Resolve Windows preflight paths, use non-signaling PID checks and a stable OS file lock; support long source paths without changing their public identities.
  • Recognize bounded, page-marked UTF-8 PDF extractions while preserving native binary PDF parsing and failure diagnostics. Release native resources retained by failed PyMuPDF constructors without clearing unrelated exception frames.
  • Repair installer preservation/argument handling, packaged resources and API compatibility checks. Correct GPU, recovery, configuration and multi-client documentation.
  • Use Node 24 and GitHub OIDC for NPM publication; verify PyPI, NPM and Docker as separate release outcomes.

Why

The changes address reproduced failures and measured retained state. The broad audit crosses the shared index/cache/publication lifecycle, so independent review and integrated failure tests cover those boundaries. The default embedding model is retained: the isolated multilingual E5 experiment did not improve evidence coverage enough to justify its larger resource cost.

7 Pillars Quality Gate

Pillar Evidence and acceptance
Security Containment and staged-write review, secret/SAST/dependency checks, no relaxed provider path validation. Existing documented Chroma advisory exceptions remain; no new exception or skip label.
Stability Real Chroma/FTS5 rollback, process restart, cache-generation, publication and MCP stdio tests. Final candidate results are recorded below.
Memory Bounded metric/cache/indexing retention; actual process RSS is separate from traced Python allocations and benchmark duration.
Versatility Required Linux/macOS/Windows × Python 3.11/3.12/3.13 matrix, plus actual Windows CPU/CUDA/AMD DirectML runs.
Scalability The integrated performance gate retains its 10% threshold. Historical/workload-incompatible rows are explicitly excluded from comparisons, not counted as improvements.
Versioning Python/NPM declarations agree at 4.10.0; CHANGELOG is consolidated; optional MCP arguments preserve the existing public API call shapes.
Quality Ruff, 17-file strict mypy selection, docstring coverage, real wheel/sdist builds and local pre-commit hooks. Legacy complexity remains documented.

Measurements and limitations

The 60 development diagnostics improved expected-source hits@10 from 33 to 37 and evidence hits@10 from 28 to 31. These cases were used during development; a separate 12-question reserve is evaluated only after runtime freeze and is not used for tuning. Source matches are not proof of complete or correct generated answers. The larger E5 comparison returned 36 source hits and 31 evidence hits; BGE remains the default.

The frozen final reserve (six PT/EN pairs, twelve questions) improved source hits@10 from 4/12 to 6/12, evidence hits@10 from 3/12 to 4/12 and MRR@10 from 0.2619 to 0.3361. Hits@1 stayed at 3/12. The improvement was confined to English; Portuguese source/evidence hits remained 0/6 in both versions. No runtime or ranking parameter was changed after this evaluation. This is a remaining cross-language limitation, not a claim of resolved multilingual quality. Across the evaluation, 180 direct and 180 MCP calls agreed; seventeen real folder-filter scenarios passed through both interfaces. Negative controls returned approximate context without matching absent markers; generated answers and abstention were not evaluated.

Final Windows CUDA reindex: 5,962 attempted files, 5,951 indexed sources, 70,083 chunks, eleven explicit empty/invalid-source errors. Chroma/FTS5/BM25 counts and vector validation agree. The indexing call took 476.009 seconds, with peak process RSS 2,473,619,456 bytes; the full monitor window was 533.403 seconds. Corpus/configuration hashes remained unchanged.

Earlier controlled local diagnostics found BM25 retained Python memory decrease from 120,711,243 to 26,859,694 bytes for 10,000 documents; histogram retention decrease from 3,201,024 to 328 bytes for 100,001 observations of one series; and 100 FTS5 updates in 100,000 rows decrease from 1.754 to 0.0618 seconds. Initial FTS5 insertion increased from 0.412 to 0.800 seconds. These are workload-specific observations, not universal speed guarantees.

Private corpus paths, content, queries and acceptance artifacts remain local. Empty/invalid sources remain visible failures. AMD DirectML on this Windows adapter does not establish Linux ROCm or Apple GPU support. CPU fallback remains available.

Migration / Breaking changes

No required index-format migration or incompatible MCP tool change. Folder filters use document-root-relative paths and reject traversal, absolute paths and escaping links. Stop legacy server instances before upgrading to the OS lock protocol; do not delete a live .guard sidecar. Keep embedding-model migrations in separate data/metadata paths.

DirectML is explicit and experimental; use an isolated ONNX environment as documented in the GPU guide. The production installation, original corpus, drivers and registry settings are unchanged.

Test plan

  • Independent review and reproduced regression cases for the original five findings.
  • Retrieval-focused tests and real BGE/E5 diagnostic comparisons.
  • Local pre-commit hooks in an isolated tracked checkout.
  • Final independent rollback-recovery review: 16/16 scenarios, including 8/8 recoveries in new Python processes; 62 additional focused tests passed.
  • Integrated Windows suite: 1,263 passed, 1 skipped, 83.57% coverage; all 5 separately selected chaos tests passed. Runtime 199f4c3, documentation head 86d44ef.
  • Final full-corpus CUDA reindex and frozen reserve evaluation; 180 direct/MCP result pairs agree. CPU/CUDA/AMD DirectML passed the same seven-source / 162-chunk real-storage scenario, including mutations and reopen.
  • CPU stress for OOM in CPU fallback: ONNXRuntime "Failed to allocate memory for requested buffer of size 503316480" when indexing minified JS / large JSON #224: 331 JS/JSON chunks, 330 full 512-token sequences, observed ONNX batches capped at 32, finite 384-dimensional vectors and no OOM; 18.5486-second indexing call and 1,477,693,440-byte peak RSS.
  • Final nine-cell CI and unchanged performance gate on published head 86d44ef: all 35 checks passed. CI, Quality Gate.

Documentation

The configuration/API, GPU setup, reindex recovery, multi-client guidance and CHANGELOG are updated. Detailed measurements and qualifications are recorded in docs/audit-2026-10-03.md, docs/audit-2026-10-04.md and docs/search-quality.md.

Reviewer checklist

  • Reviewed line-by-line
  • Verified the 7 pillars CI status checks are green
  • Verified no obvious adversarial implications
  • Approved performance impact

RetriggerConfidence Score: 3/5

The PR is not ready to merge until incremental rollback failure and post-commit rebuild reporting are corrected.

Fix All in Claude CodeFindings

  1. P1 Failed rollback goes unrecorded ▶
  2. P1 Committed swap reports failure ▶
  3. P2 Broad filters load every ID ▶
Fix with agent prompt
### Issue 1
mcp_server/server.py:2237-2243
If incremental indexing fails while replacing a document and restoring its previous vectors also fails, this path raises without recording a repair. The inventory still describes the old document, but some vectors may be missing. A later incremental run can skip the unchanged source, leaving it unrepaired.

### Issue 2
mcp_server/server.py:2896
If resetting FTS5 fails after the staging swap, such as when the new SQLite index or migration marker cannot be written, the primary collection and metadata have already committed. This exception still reports the rebuild as failed: startup force-indexes the already-replaced collection, while an MCP caller receives a misleading failure.

### Issue 3
mcp_server/server.py:3455
Every uncached search with a category or folder filter loads all matching chunk IDs from Chroma before requesting a small set of results. A broad filter over a large corpus therefore adds a corpus-sized database read and memory allocation to each distinct query, undermining bounded-memory retrieval.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR adds folder-scoped retrieval, broad indexing and rollback recovery changes, bounded metrics and indexing work, platform and parser handling, and release tooling.

  • Incremental replacement still lacks a repair record when its own vector restoration fails.
  • A post-commit FTS5 failure can be reported as a failed collection swap.
  • Broad retrieval filters materialize all eligible chunk IDs per uncached query.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Discover source files] --> B[Incremental replacement]
  B --> C[Chroma collection]
  B --> D[Metadata and repair journal]
  C --> E[Scoped candidate selection]
  D --> E
  E --> F[Semantic / BM25 / FTS5]
  F --> G[Rerank and return]
  H[Staging rebuild] --> I[Publish collection and metadata]
  I --> J[Reset derived FTS5 index]
Loading

Reviews (1) · Last reviewed commit: "docs(recovery): describe durable repair ..."

FastEmbed TextEmbedding.embed() default batch_size=256 allocates ~500MB
intermediate buffers under CPU execution with bge-small at seq_len=512.
On fragmented Windows heaps this triggered ONNXRuntime BAD_ALLOC during
ingestion of minified JS or large JSON. GPU VRAM is contiguous so 256
is safe.

Fix dispatches batch_size based on active ONNX provider: 32 (CPU) /
256 (CUDA). Exposes KNOWLEDGE_RAG_EMBED_BATCH_SIZE env override and
documents.embed_batch_size YAML key for per-workload tuning.

API surface unchanged (12 MCP tools preserved). Added 3 regression
tests and updated 3 existing mock lambdas to accept the new kwarg
(baseline 336 -> 339).

Closes #224
CI runs ruff 0.16.10 which collapses the three updated lambda mocks
back to a single line (they fit in the 120-char limit configured in
pyproject.toml). Local ruff 0.16.0 split them. Pinning to CI's version
and reformatting.

No behavior change — identical AST, same tests pass.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 144 files, which is 44 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87697977-1090-4486-9aea-f8045963d750
📥 Commits

Reviewing files that changed from the base of the PR and between 3a96fc6 and 86d44ef.

📒 Files selected for processing (144)
  • .github/PULL_REQUEST_TEMPLATE.md
  • .github/SECURITY.md
  • .github/openssf-best-practices.md
  • .github/test-count-baseline.txt
  • .github/workflows/bench-pages.yml
  • .github/workflows/ci.yml
  • .github/workflows/nightly.yml
  • .github/workflows/quality-gate.yml
  • .github/workflows/release.yml
  • .github/workflows/security.yml
  • .github/workflows/update-star-history.yml
  • .gitignore
  • .pre-commit-config.yaml
  • CHANGELOG.md
  • CONTRIBUTING.md
  • README.md
  • SECURITY.md
  • bench/dashboard/README.md
  • bench/dashboard/build.py
  • bench/dashboard/dashboard.js
  • bench/dashboard/index.html
  • bench/dashboard/styles.css
  • bench/test_bench_concurrent.py
  • bench/test_bench_fts5_lexical.py
  • bench/test_bench_memory.py
  • bench/test_bench_reindex.py
  • bench/test_bench_search.py
  • config.example.yaml
  • docs/API.md
  • docs/ARCHITECTURE.md
  • docs/CONFIGURATION.md
  • docs/INSTALLATION.md
  • docs/TROUBLESHOOTING.md
  • docs/audit-2026-10-03.md
  • docs/audit-2026-10-04.md
  • docs/features/fts5_fast_path.md
  • docs/gpu-setup.md
  • docs/reindex-operations.md
  • docs/runbooks/fts5_migration.md
  • docs/search-quality.md
  • docs/single-instance.md
  • install.ps1
  • install.py
  • install.sh
  • mcp_server/__init__.py
  • mcp_server/config.py
  • mcp_server/data/config.example.yaml
  • mcp_server/data/cybersecurity.yaml
  • mcp_server/data/developer.yaml
  • mcp_server/data/multilingual.yaml
  • mcp_server/file_transaction.py
  • mcp_server/filesystem.py
  • mcp_server/fts5_index.py
  • mcp_server/ingestion.py
  • mcp_server/instance_lock.py
  • mcp_server/metrics.py
  • mcp_server/pdf_support.py
  • mcp_server/preflight.py
  • mcp_server/publication.py
  • mcp_server/query_router.py
  • mcp_server/search_candidates.py
  • mcp_server/search_scope.py
  • mcp_server/security.py
  • mcp_server/server.py
  • npm/package.json
  • perf-baseline-v4.7.1.json
  • presets/multilingual.yaml
  • pyproject.toml
  • requirements-dev.txt
  • requirements.txt
  • scripts/audit_requirements.py
  • scripts/audit_retrieval.py
  • scripts/audit_workload.py
  • scripts/build_fts5_index.py
  • scripts/check_api_surface.py
  • scripts/check_changelog.py
  • scripts/check_perf_regression.py
  • skills/foundation/rag-onboard-context/SKILL.md
  • skills/install.sh
  • skills/maintenance/rag-evaluate-quality/SKILL.md
  • skills/maintenance/rag-index-decisions/SKILL.md
  • tests/conftest.py
  • tests/security/test_add_from_url_sanitized.py
  • tests/security/test_path_traversal.py
  • tests/security/test_prompt_injection.py
  • tests/security/test_symlink_escape.py
  • tests/support/stdio_probe_server.py
  • tests/test_api_surface_gate.py
  • tests/test_backup_retirement.py
  • tests/test_backwards_compat.py
  • tests/test_batch_parallel.py
  • tests/test_bm25_snapshots.py
  • tests/test_build_fts5_index.py
  • tests/test_chroma_optional_metadata.py
  • tests/test_config_fts5.py
  • tests/test_directml_embeddings.py
  • tests/test_embedding_batch_size.py
  • tests/test_embedding_profile.py
  • tests/test_embedding_safety.py
  • tests/test_file_transaction.py
  • tests/test_filesystem_paths.py
  • tests/test_fts5_lifecycle_integrity.py
  • tests/test_fts5_migration.py
  • tests/test_fts5_replay.py
  • tests/test_fts5_snapshot_count.py
  • tests/test_gpu_auto.py
  • tests/test_indexing_integrity.py
  • tests/test_ingestion_efficiency.py
  • tests/test_installer_no_data_loss.py
  • tests/test_installer_runtime.py
  • tests/test_instance_lock_concurrency.py
  • tests/test_instance_lock_windows.py
  • tests/test_lazy_embeddings.py
  • tests/test_lifecycle_concurrency.py
  • tests/test_locale.py
  • tests/test_main_startup.py
  • tests/test_memory_baseline.py
  • tests/test_metrics_bounded.py
  • tests/test_mutation_cache_rollback.py
  • tests/test_packaged_presets.py
  • tests/test_pdf_support.py
  • tests/test_performance_measurements.py
  • tests/test_pr98_regression.py
  • tests/test_preflight.py
  • tests/test_publication_integrity.py
  • tests/test_query_cache_generation.py
  • tests/test_query_cache_isolation.py
  • tests/test_query_memory_regressions.py
  • tests/test_reindex_resume.py
  • tests/test_retrieval_candidates.py
  • tests/test_retrieval_quality_regressions.py
  • tests/test_rollback_inventory_recovery.py
  • tests/test_rollback_repair_journal.py
  • tests/test_search.py
  • tests/test_search_scope.py
  • tests/test_security_docs.py
  • tests/test_semantic_bm25_loading.py
  • tests/test_shell_installers.py
  • tests/test_staged_logical_filename.py
  • tests/test_stdout_protection.py
  • tests/test_storage_safety.py
  • tests/test_swap_zero_downtime.py
  • tests/test_v483_hotfix.py
  • tests/test_windows_long_paths.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

socket-security Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedpypi/​onnxruntime-gpu@​1.30.0 ⏵ 1.26.07410010010070 -30

View full report

lyonzin and others added 20 commits October 3, 2026 17:28
Bumps the github-actions group with 3 updates: [actions/checkout](https://github.com/actions/checkout), [actions/setup-python](https://github.com/actions/setup-python) and [actions/setup-node](https://github.com/actions/setup-node).

Updates `actions/checkout` from 4 to 7
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v7)

Updates `actions/setup-python` from 5 to 7
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](actions/setup-python@v5...v7)

Updates `actions/setup-node` from 6 to 7
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/setup-python
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/setup-node
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit eedb00a)
Updates the requirements on [hypothesis](https://github.com/HypothesisWorks/hypothesis) to permit the latest version.
- [Release notes](https://github.com/HypothesisWorks/hypothesis/releases)
- [Commits](HypothesisWorks/hypothesis@v6.165.9...v6.168.3)

---
updated-dependencies:
- dependency-name: hypothesis
  dependency-version: 6.168.3
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit f8c51b5)
Updates the requirements on [ruff](https://github.com/astral-sh/ruff) to permit the latest version.
- [Release notes](https://github.com/astral-sh/ruff/releases)
- [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
- [Commits](astral-sh/ruff@0.16.2...0.16.9)

---
updated-dependencies:
- dependency-name: ruff
  dependency-version: 0.16.9
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit ee59179)
Updates the requirements on [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) to permit the latest version.
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst)
- [Commits](pytest-dev/pytest-rerunfailures@16.4...16.7)

---
updated-dependencies:
- dependency-name: pytest-rerunfailures
  dependency-version: '16.7'
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit b4e17cb)
Updates the requirements on [mutmut](https://github.com/boxed/mutmut) to permit the latest version.
- [Release notes](https://github.com/boxed/mutmut/releases)
- [Changelog](https://github.com/boxed/mutmut/blob/main/HISTORY.rst)
- [Commits](boxed/mutmut@3.5.0...3.8.0)

---
updated-dependencies:
- dependency-name: mutmut
  dependency-version: 3.8.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit 1c39cbd)
Updates the requirements on [pytest-memray](https://github.com/bloomberg/pytest-memray) to permit the latest version.
- [Release notes](https://github.com/bloomberg/pytest-memray/releases)
- [Changelog](https://github.com/bloomberg/pytest-memray/blob/main/docs/news.rst)
- [Commits](bloomberg/pytest-memray@v1.10.0...v1.11.0)

---
updated-dependencies:
- dependency-name: pytest-memray
  dependency-version: 1.11.0
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <[email protected]>
(cherry picked from commit 2c5e541)
@lyonzin lyonzin changed the title fix(core): bound memory and harden indexing across CPU and GPU feat(core): improve indexing recovery and scoped retrieval for v4.10.0 Oct 4, 2026
@lyonzin
lyonzin marked this pull request as ready for review October 4, 2026 12:21
@lyonzin
lyonzin merged commit fd4d6f1 into master Oct 4, 2026
38 checks passed
@lyonzin
lyonzin deleted the perf/memory-gpu-audit branch October 4, 2026 12:21
Comment thread mcp_server/server.py
Comment on lines +2237 to +2243
except Exception:
newly_created = sorted(set(ids) - set(previous["ids"]))
if newly_created:
self._write_collection.delete(ids=newly_created)
self._fts5_sync_remove_ids(newly_created)
self._restore_document_chunks(previous)
self._bm25_initialized = False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed rollback goes unrecorded

If incremental indexing fails while replacing a document and restoring its previous vectors also fails, this path raises without recording a repair. The inventory still describes the old document, but some vectors may be missing. A later incremental run can skip the unchanged source, leaving it unrepaired.

Prompt To Fix With AI
This is a comment left during a code review.
Path: mcp_server/server.py
Line: 2237-2243

Comment:
**Failed rollback goes unrecorded**

If incremental indexing fails while replacing a document and restoring its previous vectors also fails, this path raises without recording a repair. The inventory still describes the old document, but some vectors may be missing. A later incremental run can skip the unchanged source, leaving it unrepaired.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread mcp_server/server.py
except Exception as exc:
print(f"[RECOVERY] Rebuild committed; post-commit repair cleanup failed: {exc}", file=sys.stderr)
self._retire_previous_collection(prod_name, ts)
self._fts5_reset_and_rebuild()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Committed swap reports failure

If resetting FTS5 fails after the staging swap, such as when the new SQLite index or migration marker cannot be written, the primary collection and metadata have already committed. This exception still reports the rebuild as failed: startup force-indexes the already-replaced collection, while an MCP caller receives a misleading failure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: mcp_server/server.py
Line: 2896

Comment:
**Committed swap reports failure**

If resetting FTS5 fails after the staging swap, such as when the new SQLite index or migration marker cannot be written, the primary collection and metadata have already committed. This exception still reports the rebuild as failed: startup force-indexes the already-replaced collection, while an MCP caller receives a misleading failure.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

Comment thread mcp_server/server.py
where_filter = {"$and": [where_filter, source_filter]} if where_filter else source_filter
allowed_ids = None
if where_filter:
allowed_ids = frozenset(self.collection.get(where=where_filter, include=[])["ids"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Broad filters load every ID

Every uncached search with a category or folder filter loads all matching chunk IDs from Chroma before requesting a small set of results. A broad filter over a large corpus therefore adds a corpus-sized database read and memory allocation to each distinct query, undermining bounded-memory retrieval.

Prompt To Fix With AI
This is a comment left during a code review.
Path: mcp_server/server.py
Line: 3455

Comment:
**Broad filters load every ID**

Every uncached search with a category or folder filter loads all matching chunk IDs from Chroma before requesting a small set of results. A broad filter over a large corpus therefore adds a corpus-sized database read and memory allocation to each distinct query, undermining bounded-memory retrieval.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants