variant補間の再帰深さ上限をroute毎の停留所数から動的に算出 (Closes #1513)#1520
Conversation
`build_stop_route_mapping()` の `prev_chain` / `next_chain` 再帰 CTE が `depth < 10` の固定値で打ち切られていたため、メイン系統に戻るまでに 11 停留所以上ある variant 経路ではアンカー解決に失敗し、`estimated_seq` が末尾フォールバック (`mtms.max_seq + 9999`) や「next のみ解決」分岐に 落ちて停留所順が崩れていた。 route ごとの `variant_only_with_neighbors` の行数から `max_depth` を 計算する `variant_chain_limit` CTE を追加し、`prev_chain` / `next_chain` の上限をこれに置き換える。`visited` 配列で各 variant 停留所は 1 度しか 踏まないことが保証されているため、stop 数 + 1 はサイクル防止と整合した タイトな上限になる。 長い variant チェーン (M01 → V01..V12 → M15) のシナリオで V02..V11 が 両端を再帰解決して中央付近に挿入されることを検証する SQL 回帰テスト `test_build_stop_route_mapping_long_variant_chain_dynamic_limit` を追加。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesVariant Chain Recursion Depth Limit
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
概要
build_stop_route_mapping()のprev_chain/next_chain再帰 CTE が固定のdepth < 10で打ち切られていたため、メイン系統に戻るまでに 11 停留所以上ある variant 経路でアンカー解決に失敗し、estimated_seqが末尾フォールバック (mtms.max_seq + 9999) や「next のみ解決」分岐に落ちて停留所順が崩れる不具合があった。再帰深さの上限を route ごとの variant-only 停留所数から動的に算出するように修正する。変更の種類
変更内容
variant_chain_limitCTE を新設し、route ごとにvariant_only_with_neighborsの行数 + 1 をmax_depthとして算出する。visited配列で各 variant 停留所は 1 度しか踏まないことが保証されているため、stop 数 + 1 はサイクル防止と整合したタイトな上限になる。prev_chain/next_chainのWHERE pc.depth < 10/nc.depth < 10をvariant_chain_limitへの JOIN 経由でdepth < vcl.max_depthに置き換え。M01 → V01..V12 → M15) のシナリオで V02..V11 が両端 (M01, M15) を再帰解決して中央付近 (~7.91〜8.09) に補間されることを検証する SQL 回帰テストtest_build_stop_route_mapping_long_variant_chain_dynamic_limitを追加。旧実装では V11 がdepth < 10で打ち切られ M14 付近 (~14.8) に流される回帰が、本テストで検出できる。テスト
cargo fmt --all -- --checkが通ることcargo clippy -- -D warningsが通ることcargo test(SQLX_OFFLINE=true)が通ること加えて、
TEST_DATABASE_URLを指定してcargo test -p stationapi --features integration-tests --bin stationapi build_stop_route_mappingを実行し、既存 6 件 + 新規 1 件 = 計 7 件の SQL 回帰テストが全て pass することを確認済み。関連Issue
Closes #1513
スクリーンショット(任意)
Summary by CodeRabbit
バグ修正
テスト