Skip to content

feat(index): add mapping_fn param to build_index#10

Merged
protosphinx merged 1 commit into
mainfrom
bot/build-index-mapping-fn
May 8, 2026
Merged

feat(index): add mapping_fn param to build_index#10
protosphinx merged 1 commit into
mainfrom
bot/build-index-mapping-fn

Conversation

@protosphinx
Copy link
Copy Markdown
Member

Why

build_index was hardcoded to regex_mapping, giving callers no way
to use the composable strategies added in v0.5 (embedding_mapping,
compose_mappings) and v0.6 (llm_mapping). The README explicitly
recommends stacking strategies ("regex first, embedding to fill gaps,
LLM for the long tail"), but there was no way to wire that stack into
the index. This closes the gap.

What

  • pm_rag/index.py: adds a keyword-only mapping_fn: MappingFn | None
    parameter to build_index. Defaults to None, which preserves the
    existing regex_mapping behavior unchanged. Also exports MappingFn
    as a type alias for documentation purposes.
  • tests/test_index.py: adds 4 new tests covering the new parameter:
    custom mapping function is used, default None matches explicit
    regex_mapping, compose_mappings works as the mapping_fn, and
    explicit None falls back to regex.

Tests

  • python -m pytest -q: 83 passed (was 79 before this PR).
  • ruff check: all checks passed.
  • New tests: test_build_index_custom_mapping_fn_is_used,
    test_build_index_default_matches_regex_mapping,
    test_build_index_with_composed_strategy,
    test_build_index_mapping_fn_none_uses_regex.

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed): 63 lines
  • no public-API surface change: pm_rag/__init__.py not touched; build_index signature is backward-compatible (new keyword-only optional param)
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended: 4 new tests in tests/test_index.py

Generated by Claude Code

build_index was hardcoded to regex_mapping, giving callers no way to
plug in the embedding, LLM, or composed strategies added in v0.5/v0.6.
The new keyword-only mapping_fn param accepts any strategy callable
with the standard (events, symbols) signature and defaults to None,
which preserves the existing regex_mapping behavior unchanged.
@protosphinx protosphinx added the automated Opened by the daily bot label May 8, 2026 — with Claude
@protosphinx protosphinx merged commit b0d8c80 into main May 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant