paths: walk every simple path between two concepts - #424
Conversation
POST /contexts/{name}/paths (#418) — the 手繰り itself: activate
spreads outward and explore sweeps a neighborhood, but neither answers
"how are these two related?" without the client re-walking the graph.
Each trail carries the whole concept path plus its associations in
walk order with full attributions.
Traversal follows explore's exact discipline (bidirectional, labels
never bridge, retracted edges never bridge, ADR 0009 §6.3's
schema:type exclusion via the same monomorphized-visible-closure
pattern). Ranking is deterministic: distance ascending, then
weakest-link strength descending on raw cumulative |sum| — the same
corroboration-outranks-emphasis discipline activate documents — then
insertion order. Simple-path enumeration is combinatorial in the worst
case, so one call examines at most a fixed edge budget and reports
capped: true honestly instead of a silently complete-looking total.
Exposed as the paths MCP tool, in both core SDKs per
sdk/spec/surface.yaml, pinned as a wire-contract fixture (additive,
HTTP_CONTRACT unchanged), classified Role::Read, counted as
taguru_searches_total{op="paths"}, and documented in the /protocol
manual, README, and docs site.
Closes #418
Claude-Session: https://claude.ai/code/session_014RfogjbkTt5f14rz8fzYgP
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough概念間の単純パス探索を追加しました。コア走査、HTTP API、MCP、Python SDK、TypeScript SDK、ワイヤー契約、メトリクス、文書、テストを更新しました。 Changespaths 機能
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant HTTP as POST /contexts/{name}/paths
participant Context as Context::paths
participant Resolver as association resolver
Client->>HTTP: origins, targets, max_depth, limit
HTTP->>Context: enumerate simple paths
Context->>Resolver: resolve path associations
Resolver-->>HTTP: TrailOut matches
HTTP-->>Client: PathsPage with total and capped
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
src/context/traverse.rs (1)
1137-1149: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win複数起点と重複起点のテストが不足しています。
paths_implは起点をseen_originsで重複排除し、呼び出し側の順序を保つと 491-493 行のコメントで宣言しています。しかし追加したテストはすべて単一起点です。重複排除が壊れると、同じ trail が二重に列挙されtotalが水増しされます。この不変条件は現状テストで保証されていません。同じ起点を二度渡した場合と、複数の異なる起点を渡した場合の
totalを検証するテストを追加してください。💚 追加テストの例
#[test] fn paths_deduplicates_repeated_origins_and_walks_every_distinct_one() { let mut context = Context::default(); context.associate("a", "r", "t", 1.0).unwrap(); context.associate("b", "r", "t", 1.0).unwrap(); // The same origin twice must not enumerate the same trail twice. assert_eq!(context.paths(&["a", "a"], &["t"], 10, 10).total, 1); // Two distinct origins each contribute their own trail. let both = context.paths(&["a", "b"], &["t"], 10, 10); assert_eq!(both.total, 2); }以上は path instructions に従った指摘です。
{src,tests}/**/*.rs: 「テストされていないエッジケース・失敗系(エラー・タイムアウト・不正な入力)の欠落」を指摘してください。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/context/traverse.rs` around lines 1137 - 1149, Add a test near paths_returns_nothing_for_unknowns_zero_depth_or_self that verifies paths deduplicates repeated origins while traversing every distinct origin. Build separate trails from two origins to one target, assert repeated input such as ["a", "a"] yields total 1, and assert ["a", "b"] yields total 2.Source: Path instructions
src/llm-protocol.md (1)
65-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win引用解決の列挙に
pathsを追加してください。
pathsもtrails_outでsection/locatorを解決します。項目5と/contexts/{name}/citationsの列挙にpathsを追加してください。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/llm-protocol.md` around lines 65 - 70, 項目5と「/contexts/{name}/citations」の引用解決対象に paths を追加し、trails_out と同様に paths 内の section/locator を解決するよう llm-protocol.md の列挙を更新してください。sdk/typescript/tests/integration/client.test.ts (1)
159-164: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win両SDKの
paths統合テストを完全なレスポンス契約まで拡張してください。現在のテストは単一路径の一部のフィールドだけを検証しています。次の変更を各テストに追加してください。
sdk/typescript/tests/integration/client.test.ts#L159-L164:Trail.distance、Trail.strength、関連付けのsubject、object、weight、attributions、およびmax_depth境界を検証してください。sdk/python/tests/integration/test_full_loop.py#L162-L167:Trail.distance、Trail.strength、関連付けのsubject、object、weight、attributions、およびmax_depth境界を検証してください。As per path instructions: テストでは未検証のエッジケースと不完全なアサーションを指摘します。
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@sdk/typescript/tests/integration/client.test.ts` around lines 159 - 164, 両SDKの paths 統合テストを完全なレスポンス契約まで拡張してください。sdk/typescript/tests/integration/client.test.ts の ctx.paths と threads の検証に Trail.distance、Trail.strength、関連付けの subject・object・weight・attributions、および max_depth 境界のアサーションを追加してください。sdk/python/tests/integration/test_full_loop.py の対応する paths テストにも同じ検証を追加し、既存の単一路径アサーションを維持してください。Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/api/explore.rs`:
- Around line 195-202: Update the search logging call in the relevant explore
handler to remove the externally supplied context, origins, and targets fields
from tracing::info!. Keep only the search operation context, request-independent
metadata, and the hit count (hits = result.total), while preserving the existing
TAGURU_LOG_SEARCHES-controlled logging behavior.
In `@src/mcp/schema.rs`:
- Around line 423-436: Update the max_depth property in the paths schema to
declare integer bounds matching the API contract: minimum 0 and maximum 10. Keep
its existing description and all other schema properties unchanged.
---
Nitpick comments:
In `@sdk/typescript/tests/integration/client.test.ts`:
- Around line 159-164: 両SDKの paths
統合テストを完全なレスポンス契約まで拡張してください。sdk/typescript/tests/integration/client.test.ts の
ctx.paths と threads の検証に Trail.distance、Trail.strength、関連付けの
subject・object・weight・attributions、および max_depth
境界のアサーションを追加してください。sdk/python/tests/integration/test_full_loop.py の対応する paths
テストにも同じ検証を追加し、既存の単一路径アサーションを維持してください。
In `@src/context/traverse.rs`:
- Around line 1137-1149: Add a test near
paths_returns_nothing_for_unknowns_zero_depth_or_self that verifies paths
deduplicates repeated origins while traversing every distinct origin. Build
separate trails from two origins to one target, assert repeated input such as
["a", "a"] yields total 1, and assert ["a", "b"] yields total 2.
In `@src/llm-protocol.md`:
- Around line 65-70: 項目5と「/contexts/{name}/citations」の引用解決対象に paths
を追加し、trails_out と同様に paths 内の section/locator を解決するよう llm-protocol.md
の列挙を更新してください。
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 640460a6-d6af-4bb0-b1cf-650bb2514e22
⛔ Files ignored due to path filters (1)
sdk/python/uv.lockis excluded by!**/*.lock
📒 Files selected for processing (33)
CHANGELOG.mdREADME.mddocs/concepts.htmldocs/modeling.htmlsdk/python/src/taguru/__init__.pysdk/python/src/taguru/_async/client.pysdk/python/src/taguru/_models.pysdk/python/src/taguru/_sync/client.pysdk/python/tests/integration/test_full_loop.pysdk/python/tests/unit/test_wire_contract.pysdk/spec/surface.yamlsdk/typescript/src/client.tssdk/typescript/src/index.tssdk/typescript/src/models.tssdk/typescript/tests/integration/client.test.tssdk/typescript/tests/unit/wire-contract.test.tssrc/api.rssrc/api/explore.rssrc/auth.rssrc/context.rssrc/context/traverse.rssrc/llm-protocol.mdsrc/main.rssrc/mcp.rssrc/mcp/route.rssrc/mcp/schema.rssrc/metrics/taxonomy.rstests/fixtures/wire/http/paths.jsontests/fixtures/wire/shapes.jsontests/http_api/contract.rstests/http_api/mcp_basics.rstests/http_api/retrieval_core.rstests/http_api/schema_type_label.rs
CodeRabbit on PR #424: the paths tool's max_depth declared only "integer", so a negative value would pass MCP schema validation and surface as a 422 deserialization failure server-side — the exact failure mode every limit property's minimum: 0 exists to catch early. Applied to explore's max_depth too, which had the same gap. No maximum: 10, deliberately: the server clamps larger depths rather than refusing them (same contract as every limit, which caps at 1000 while declaring only the minimum), and a schema maximum would make MCP refuse what HTTP accepts. Claude-Session: https://claude.ai/code/session_014RfogjbkTt5f14rz8fzYgP
Summary
POST /contexts/{name}/paths— 2つの概念の間を実際に手繰るエンドポイント(#418)。activate(起点から拡散)とexplore(近傍走査)では「AとBはどう関係しているか」に答えられなかったギャップを埋める。origins→targets間の全simple pathを最短順に返し、各trailは概念列(path)と歩いたassociation群(attributions込み、walk順)を運ぶ。設計判断
schema:type除外(explore_excludingと同じmonomorphized-visible-closureパターンのpaths_excluding)activateと同じ規律)→ 挿入順capped: trueで報告(totalは下界)。網羅に見える切り捨てをしないmax_depthはexploreと同じ天井10、limitはデフォルト10・上限100(trailはassociationの連なりで単発マッチより重いためMAX_MATCH_LIMITより狭い)各層の追従
pathsツール(stdio bridge //mcp両対応、必須引数refusalテスト込み)paths()(async source → unasync再生成)/ TypeScriptpaths()、sdk/spec/surface.yaml登録、surface parity両言語通過tests/fixtures/wire/http/paths.json固定(additive、HTTP_CONTRACT不変)、shapes.json、Python/TSの契約テストにtyped decode追加auth.rsでRole::Read分類、/metricsにtaguru_searches_total{op="paths"}/protocolマニュアル(使い分け+エンドポイント表)、README、docs(concepts/modeling)、CHANGELOGTest plan
cargo fmt/cargo clippy --all-targets(警告なし)/cargo test全通過(2,150件)Closes #418
https://claude.ai/code/session_014RfogjbkTt5f14rz8fzYgP
Summary by CodeRabbit
paths機能を追加しました。