Skip to content

refactor: extract search_passages/cross_search_passages's shared cache-probe block (#605) - #636

Merged
t0k0sh1 merged 1 commit into
mainfrom
605-api-sources-dedup
Aug 13, 2026
Merged

refactor: extract search_passages/cross_search_passages's shared cache-probe block (#605)#636
t0k0sh1 merged 1 commit into
mainfrom
605-api-sources-dedup

Conversation

@t0k0sh1

@t0k0sh1 t0k0sh1 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

Test plan

  • cargo fmt
  • cargo clippy --all-targets (clean)
  • cargo test (full suite, all binaries green — http_api integration tests cover both handlers' exact/semantic cache paths and search_passages' ADR 0008 span attributes end-to-end, confirming the extraction preserved exact behavior for both)
  • Pre-PR diff-scoped gate (cargo mutants --in-diff): 2 caught + 2 unviable, 0 missed

Closes #605

https://claude.ai/code/session_0198T2iKZ17g3tt2bdNq1ju8

Summary by CodeRabbit

  • 改善
    • 検索結果のキャッシュ判定を統一し、完全一致・セマンティック一致のキャッシュヒット時により迅速に結果を返せるようになりました。
    • 単一コンテキスト検索とクロスコンテキスト検索で、キャッシュヒット種別や補完情報を一貫して扱えるようになりました。
    • キャッシュに完全一致しない場合も、セマンティック検索による補完情報が提供されるようになりました。

…e-probe block (#605)

#534's registry search/cache duplication audit, fourth and final
follow-up PR (first: #632, second: #605-search-vectorlane, third:
#605-cache-layer-dedup).

search_passages and cross_search_passages duplicated ~50 lines of
lookup -> semantic-probe -> fill logic character-for-character but for
one differing search-log field name (context vs contexts) and
search_passages' span.record calls, which cross_search_passages has
never had a span to make. Extracted into passage_search_cache_probe,
parameterized by two logging closures (tracing field names are
macro-time identifiers, so the differing field can't be shared inside
one macro call) and an on-hit hook that search_passages uses to record
its span and cross_search_passages leaves a no-op.

Found while extracting, not fixed here: cross_search_passages carries
no taguru.passage_search-equivalent span at all, so its cache-outcome
attributes (ADR 0008 SS6) are invisible where search_passages' are
visible. Giving cross searches their own span is a bigger design
question (one span for the whole multi-target fan-out? per-target
children?) than this duplication cleanup covers — worth a follow-up
issue.

Closes #605

Claude-Session: https://claude.ai/code/session_0198T2iKZ17g3tt2bdNq1ju8
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 50675a00-ab3b-44c6-a7ec-b905a8509497

📥 Commits

Reviewing files that changed from the base of the PR and between 3aafa7e and 01062f5.

📒 Files selected for processing (2)
  • src/api/sources.rs
  • src/registry.rs

📝 Walkthrough

Walkthrough

検索キャッシュ探索を passage_search_cache_probe に集約しました。単一コンテキスト検索とクロスコンテキスト検索は、キャッシュヒット時に応答し、未ヒット時にセマンティック補填情報を後続検索へ渡します。

Changes

検索キャッシュ探索

Layer / File(s) Summary
共通キャッシュプローブ
src/api/sources.rs, src/registry.rs
passage_search_cache_probe が完全一致とセマンティック一致を探索します。ヒット時はキャッシュ内容を再生し、未ヒット時はセマンティック補填情報を返します。SemanticServepub(crate) で再エクスポートします。
検索処理への統合
src/api/sources.rs
単一コンテキスト検索とクロスコンテキスト検索が共通プローブを使用します。キャッシュ属性とログ記録を引き継ぎ、未ヒット時は補填情報を新規検索へ渡します。

Estimated code review effort: 4 (Complex) | ~45 minutes

Mergeability Score: ⚪ Minimal · up to 01062

This PR consolidates duplicated cache-probe logic without a reported behavior change; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant SearchAPI
  participant passage_search_cache_probe
  participant SemanticCache
  SearchAPI->>passage_search_cache_probe: キャッシュキーと検索条件を渡す
  passage_search_cache_probe->>SemanticCache: 完全一致またはセマンティック一致を探索
  SemanticCache-->>passage_search_cache_probe: キャッシュ結果または補填情報
  passage_search_cache_probe-->>SearchAPI: Answered または Fresh
Loading

Possibly related PRs

  • t0k0sh1/taguru#610: src/api/sources.rs の完全一致およびセマンティックキャッシュ探索を扱うため、コード上の関連性があります。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルはsearch_passagesとcross_search_passagesの共有キャッシュ探索処理の抽出を明確に示しています。
Linked Issues check ✅ Passed [#605]の主要要件である検索キャッシュ探索処理の重複排除を実装し、関連する公開チェックも満たしています。
Out of Scope Changes check ✅ Passed 変更は[#605]のキャッシュ探索処理の共通化と、その利用に必要なSemanticServeの再エクスポートに限定されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 605-api-sources-dedup

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

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.

検索/キャッシュ層の重複コード・doc陳腐化

1 participant