Skip to content

Chore/regexp audit#4

Merged
nickroci merged 5 commits into
mainfrom
chore/regexp-audit
May 22, 2026
Merged

Chore/regexp audit#4
nickroci merged 5 commits into
mainfrom
chore/regexp-audit

Conversation

@nickroci

Copy link
Copy Markdown
Owner

No description provided.

nickroci and others added 5 commits May 22, 2026 12:56
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>
@nickroci nickroci merged commit d190539 into main May 22, 2026
3 checks passed
@nickroci nickroci deleted the chore/regexp-audit branch May 27, 2026 13:02
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