Chore/regexp audit#4
Merged
Merged
Conversation
Three coupled changes:
1. Expose embedding_search as an in-process MCP tool alongside
bm25_search in library_tools.py. Wrapped via the existing
EmbeddingIndex in tools/search/embeddings.py. Same shape as
bm25_search — {query, k} to top-k results as text. Registered
in _PATH_FREE_TOOLS and added to both Librarian and Scholar
allowed_tools. New accessor fully_qualified_embedding_name().
make_library_mcp_server's tool closures now delegate to three
module-level helpers (_run_bm25_search / _run_embedding_search
/ shared _format_hit_lines + _parse_search_args) to keep the
factory function under ruff's C901 complexity cap.
2. Update Librarian + Scholar prompts to tell Claude to fan out
BM25 and embedding searches IN PARALLEL — multiple tool_use
blocks per turn, run concurrently by the SDK. Parallel guidance
is the lever that gets the recall win (semantic + lexical)
without paying the tool-budget cost of sequential calls.
3. Delete the regex pre-pass. _SEED_PATTERNS, extract_seed_phrases,
attach_bm25_hits, format_bm25_seeds, _BM25Like, BM25HitDict,
SeedWithHits were defined in librarian_prompt.py with a full
test suite but ZERO production callers. Eight tests deleted, no
behavioural change. Net: ~130 lines of natural-language regex gone.
Other re.compile sites in the codebase are all structural (YAML
frontmatter delim, wikilink syntax, slugify, filename sanitizer,
BM25 tokenizer) — verified by audit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
# Conflicts: # src/hooks/test_user_prompt_submit.py
…at --check 5 daemon files (1 source, 4 tests) had small format drift that pre-commit never caught because its ruff-format hook only runs on staged files, while CI runs ``ruff format --check .`` against the whole tree. Mechanical reformat only — no logic changes. ruff check, pyright, and the full pytest suite (439 tests, 90.17%) all still pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the upstream astral-sh/ruff-pre-commit hooks (which run on staged files only) with six local hooks — ruff check --fix and ruff format, one of each per package, with pass_filenames: false. Same shape as the pytest pre-push hooks. This way pre-existing format/lint drift on files that no current commit touches still gets caught and auto-fixed locally, rather than ambushing CI's `ruff format --check .` later. If the hook modifies files, pre-commit fails the commit and the user re-stages — standard auto-fix flow. Caught the original 5-file daemon format drift on the previous push; this change prevents the same class of drift from recurring. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.