Skip to content

fix(mcp): exclude refresh_metadata.json from searchable KB - #351

Merged
tonythethompson merged 7 commits into
mainfrom
fix/kb-exclude-refresh-metadata
Aug 17, 2026
Merged

tonythethompson merged 7 commits into
mainfrom
fix/kb-exclude-refresh-metadata

Conversation

@tonythethompson

@tonythethompson tonythethompson commented Aug 17, 2026 •

Copy link
Copy Markdown
Owner

Problem

KB Auto-Update workflow runs #2 (Aug 10) and #3 (Aug 17) failed in the Python MCP tests step:

  • tests/test_index_store.py::test_docs_shipped_index_loads
  • tests/test_index_store.py::test_get_or_build_uses_shipped_without_encode
  • tests/test_build_kb_index.py::test_skips_build_when_indexes_up_to_date
  • (run chore: bump the react group across 1 directory with 2 updates #3) 2 teardown errors in tests/test_tools.py::test_search_olive_documentation*

Failed runs: 31362669221, 32001066709

Root cause

update_kb.py / expand_kb.py write refresh_metadata.json into olive_mcp_server/knowledge_base/ as a provenance sidecar. Unlike the other two generator outputs (update_report.json, candidate_quirks.json), it was missing from _EXCLUDED_KB_FILES in docs_search.py, so its run-specific string leaves (timestamps, fingerprints, changed-file lists) were folded into the searchable KB.

Evidence from run #3:

  • Repo-clean hash matches the shipped manifest exactly (4711 snippets)
  • The run's refresh_metadata.json artifact flattens to exactly 14 string leaves; CI logged 4725 snippets during the attempted rebuild (4711 + 14)
  • Hash drift broke the shipped-index tests; semantic search then fell back to runtime encoding of all snippets, exceeded the 8s budget, and left the budget worker in flight at teardown (the 2 errors)

Run #1 (Aug 3) passed only because the shipped-index tests did not exist yet at that SHA.

Fix

  • Add refresh_metadata.json to _EXCLUDED_KB_FILES so generator sidecars never affect the KB content hash
  • Add regression test test_generator_sidecars_excluded_from_kb_hash covering all three sidecars

Verification

  • New regression test fails without the fix (hash drift reproduced) and passes with it
  • 30 tests in test_docs_search_semantic.py + test_index_store.py + test_build_kb_index.py pass
  • 36 tests in test_tools.py pass (teardown-error suite)
  • Dropped run chore: bump the react group across 1 directory with 2 updates #3's actual refresh_metadata.json artifact into the KB dir and re-ran the shipped-index suites: all pass
  • Shipped indexes are not rebuilt — the committed index already matches the committed KB; this change keeps them aligned

Review in cubic

update_kb.py/expand_kb.py write refresh_metadata.json into the knowledge_base directory, but it was not in _EXCLUDED_KB_FILES. Its run-specific string leaves drifted the docs_kb content hash from the shipped index on every KB Auto-Update workflow run, failing the shipped-index tests and forcing slow runtime re-encoding. Add it to the exclusion set and add a regression test covering all three generator sidecars.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @tonythethompson, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review available on request

  • 🔍 Trigger review

Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment @coderabbitai review to review the latest changes. For a full review, comment @coderabbitai full review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 23da98fb-cad4-4393-b825-89a1cf29537d


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.

@opencode-agent

Copy link
Copy Markdown
Contributor

No actionable findings.

The new exclusion correctly applies to both runtime searches and shipped-index hashing, and the regression test covers all three generator sidecars. py_compile and git diff --check pass. Full pytest execution was unavailable because pytest and numpy are not installed in the environment.

New%20session%20-%202026-08-17T07%3A27%3A27.228Z
opencode session  |  github run

@kilo-code-bot

kilo-code-bot Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • olive-mcp-server/olive_mcp_server/tools/docs_search.py
  • olive-mcp-server/tests/test_docs_search_semantic.py

Reviewed by step-3.7-flash · Input: 44.4K · Output: 3.1K · Cached: 360.8K

@github-actions

Copy link
Copy Markdown
Contributor

Qodana for JS

238 new problems were found

Inspection name Severity Problems
Import can be shortened 🔶 Warning 146
Exception used for local control-flow 🔶 Warning 35
Redundant local variable 🔶 Warning 22
Syntax errors and unresolved references in JSDoc 🔶 Warning 12
Pointless statement or boolean expression 🔶 Warning 5
Unused local symbol 🔶 Warning 3
Redundant 'if' statement 🔶 Warning 2
Mismatched JSDoc and function signature 🔶 Warning 1
Unused assignment 🔶 Warning 1
Pointless arithmetic expression 🔶 Warning 1
Deprecated symbol used ◽️ Notice 5
Duplicated code fragment ◽️ Notice 4
Missing await for an async function call ◽️ Notice 1

☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@tonythethompson

Copy link
Copy Markdown
Owner Author

/oc review

@opencode-agent

Copy link
Copy Markdown
Contributor

No actionable findings.

The fix is minimal and correctly targeted: adding refresh_metadata.json to _EXCLUDED_KB_FILES (docs_search.py:41-45) is consistent with the existing exclusions for update_report.json and candidate_quirks.json, and applies to both _iter_kb_json_files() (runtime search) and the content hash path (since both flow through that one filter). The regression test test_generator_sidecars_excluded_from_kb_hash (test_docs_search_semantic.py:401-432) covers all three sidecars with a real hash-drift assertion — it would fail without the fix and passes with it. py_compile passes; pytest/numpy were unavailable in this environment so the test suite was not executed locally (CI will verify).

Summary index:

  • Overall: clean, mergeable fix with a proper regression test.
  • No findings to thread.

New%20session%20-%202026-08-17T10%3A22%3A21.035Z
opencode session  |  github run

@tonythethompson

Copy link
Copy Markdown
Owner Author

/oc fix failing CI Python test

@opencode-agent

Copy link
Copy Markdown
Contributor

All verified. Working tree is clean (fix already in the PR); no code changes were needed.

Summary — /oc fix failing CI Python test (PR #351)

The PR already contains the complete fix; I verified it end-to-end since no review threads on this PR were actionable (coderabbit/opencode ×2/kilo all reported no findings; sourcery hit its rate limit).

Verified

  • Fix in place: refresh_metadata.json added to _EXCLUDED_KB_FILES (docs_search.py:41-45) — the single filter shared by runtime search (_iter_kb_json_files) and shipped-index content hashing, so sidecars can't drift the hash.
  • Regression test test_generator_sidecars_excluded_from_kb_hash (test_docs_search_semantic.py:411-432) covers all three generator sidecars.
  • Fails without the fix (hash 5df30aa… vs 81c8655… — reproduced hash drift), passes with it.
  • Previously-failing suites: test_index_store.py + test_build_kb_index.py + test_docs_search_semantic.py → 30 passed (incl. the two test_index_store and one test_build_kb_index failures named in the body); test_tools.py → 36 passed (teardown-error suite).
  • Full Python suite: 690 passed, 1 skipped, 0 failures.
  • Committed knowledge_base/ contains no sidecar files, so the shipped index stays aligned (no rebuild needed).

Threads resolved: none — no review threads existed on the PR.

Remaining risk: low. The fix is minimal, single-filter, regression-tested, and the full suite passes locally.

New%20session%20-%202026-08-17T10%3A26%3A16.877Z
opencode session  |  github run

@tonythethompson
tonythethompson merged commit 0090ab6 into main Aug 17, 2026
10 of 12 checks passed
@tonythethompson
tonythethompson deleted the fix/kb-exclude-refresh-metadata branch August 17, 2026 11:26
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.

1 participant