Skip to content

improve(backend): スキル推論のキャップを実データでチューニング(ADR-0016 #478)#483

Merged
yusuke0610 merged 2 commits into
mainfrom
improve/tune-skill-scan-caps
Jul 8, 2026
Merged

improve(backend): スキル推論のキャップを実データでチューニング(ADR-0016 #478)#483
yusuke0610 merged 2 commits into
mainfrom
improve/tune-skill-scan-caps

Conversation

@yusuke0610

@yusuke0610 yusuke0610 commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

連携本人(yusuke0610)の実データに対して本番の収集コード(github_collector)を当て、キャップ値ごとの打ち切り発生状況と「値を変えた場合の検出数推移」を計測し、閾値を見直しました。

  • verify(D6): グローバル 30 件 → エコシステム別 50 件に変更。monorepo(npm+pypi 同居)では辞書順先頭のエコシステム(backend/)が枠を使い切り、他エコの依存昇格が 0 件になる「押し出し」が発生していました。計測で 50 件でも単一エコのリポは全量走査に収まり、monorepo でも中規模リポの昇格を回収できることを確認
  • IaC(D10): 30 → 60 件に引き上げ。30 では resource 20 種中 11 種を取りこぼし、実測で 50 件で全量一致
  • manifest(D9)と各深さ上限: 実データで打ち切りゼロ・寄与ゼロを確認し据え置き
  • ADR-0016 に計測結果と判断根拠を追記
  • エコシステム別キャップの回帰テスト 2 件を追加

計測詳細

  • 対象: yusuke0610 の 4 リポ(devforge, glutton_map, pGo-snap-cleaner, fudge.com)
  • devforge(monorepo・npm+pypi): 全量 26 件昇格 / グローバル 30 件では 9 件のみ / エコ別 50 件では 17 件 / 全量走査で 26 件
  • glutton_map(go+npm): グローバル 30 件で 9/10、全量走査で 10/10(エコ別 30 件で全量一致)

Test Plan

  • make ci pass(lint/test/build)
  • collector テスト +2 件(エコシステム別キャップの有無確認)
  • ADR に計測結果と改訂履歴を記録

Notes

  • スキーマ・API 契約は不変(migration / codegen 不要)
  • 計測時に fetch_repo_tree の 403 握り込み(リトライ不経由)を確認しましたが、今回範囲外として未対応

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved repository analysis so source file sampling is now handled more consistently across ecosystems, reducing missed results in larger projects.
    • Increased IaC scanning coverage, helping more infrastructure files be included in analysis.
    • Partial results are now reported more accurately when scanning limits are reached.
  • Documentation

    • Updated the design notes to reflect the latest tuning and scanning behavior.

連携本人の実データに収集コードを当てて打ち切り発生状況とキャップ反実仮想を
計測し、閾値を見直す。

- verify(D6): ソースキャップをグローバル 30 件 → エコシステム別 50 件へ変更。
  monorepo で辞書順先頭のエコシステムが枠を使い切り、direct 依存 26 件中
  17 件が昇格漏れしていた(順序戦略の変更は浅い順に勝てないことを確認済み)
- IaC(D10): 件数キャップを 30 → 60 へ引き上げ。30 では infra/modules/ 配下の
  resource 20 種中 11 種を取りこぼしていた(50 で全量一致、余裕込みで 60)
- manifest(D9)と各深さ上限は実データで打ち切りゼロ・寄与ゼロを確認し据え置き
- ADR-0016 に計測結果ベースの判断根拠と改訂履歴を追記
- エコシステム別キャップの回帰テスト 2 件を追加

スキーマ・API 契約は不変(migration / codegen 不要)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added backend バックエンド documentation Improvements or additions to documentation test テスト追加・修正 labels Jul 8, 2026
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yusuke0610, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c6c6014-12a7-4847-8ab5-2bcc48f0c83d

📥 Commits

Reviewing files that changed from the base of the PR and between 12cad7a and 5a13151.

📒 Files selected for processing (1)
  • backend/app/services/intelligence/github_collector.py
📝 Walkthrough

Walkthrough

Changes replace a single global source-extraction cap with an ecosystem-specific cap (50) and raise the IaC scan cap (30→60) in the GitHub collector. Source selection now buckets paths by scanner ecosystem before applying per-ecosystem sampling and OR-aggregating truncation flags. Tests and ADR documentation are updated accordingly.

Changes

Ecosystem-based source cap change

Layer / File(s) Summary
Cap constants and per-ecosystem selection logic
backend/app/services/intelligence/github_collector.py
Replaces global _SOURCE_MAX_COUNT with _SOURCE_MAX_COUNT_PER_ECOSYSTEM=50, raises _INFRA_MAX_COUNT to 60, and changes _collect_repo_signals to bucket paths by scanner.ecosystem, applying _select_shallow per ecosystem and OR-aggregating the source_dropped flag.
Tests validating per-ecosystem caps
backend/tests/test_github_collector_extended.py
Adds tests confirming the ecosystem cap applies independently to each ecosystem without push-out across ecosystems, and that hitting the cap marks results as partial=True.
ADR documentation update
docs/adr/0016-github-skill-inference.md
Updates verify-stage migration conditions and adds a 2026-07 revision-history entry documenting the global-to-ecosystem source cap change and the IaC cap increase.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • yusuke0610/devforge#445: Implements the original _collect_repo_signals sampling foundation (_SOURCE_MAX_COUNT/_SOURCE_MAX_DEPTH) that this PR tunes into an ecosystem-specific cap.
  • yusuke0610/devforge#449: Introduced the IaC (_INFRA_MAX_COUNT) cap and infra_partial/drop behavior that this PR further modifies.

Suggested labels: feature

🚥 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 PRの主変更であるスキル推論キャップの実データによる調整とADR更新を適切に要約しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch improve/tune-skill-scan-caps

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
backend/app/services/intelligence/github_collector.py (1)

176-188: 🧹 Nitpick | 🔵 Trivial

Per-ecosystem bucketing and OR-aggregation logic is correct.

Each ecosystem gets an independent 50-file cap, source_dropped is properly OR-aggregated, and path_scanners[path] lookup is safe since selected_sources only contains paths from path_scanners.

Operational note: The total source-file fetch budget per repo changed from a fixed 30 to up to 50×N_ecosystems (e.g., ~100 for a typical 2-ecosystem monorepo, up to ~200 for 4 ecosystems). Each fetch is a sequential GitHub API call. Consider monitoring API rate-limit consumption and collection latency after deployment, especially for users with many monorepo-style repos.

🤖 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 `@backend/app/services/intelligence/github_collector.py` around lines 176 -
188, The per-ecosystem selection in github_collector.py is fine, but the new
budget can increase total GitHub API calls substantially across ecosystems. Add
lightweight observability around the source-fetch loop in github_collector.py
(near the _select_shallow / selected_sources flow) to record total source files
fetched, dropped counts, and any rate-limit/backoff behavior, so deployment
impact on latency and API quota can be monitored. If there is an existing
metrics or logging path in GitHubCollector, reuse it instead of adding a new
mechanism.
🤖 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.

Nitpick comments:
In `@backend/app/services/intelligence/github_collector.py`:
- Around line 176-188: The per-ecosystem selection in github_collector.py is
fine, but the new budget can increase total GitHub API calls substantially
across ecosystems. Add lightweight observability around the source-fetch loop in
github_collector.py (near the _select_shallow / selected_sources flow) to record
total source files fetched, dropped counts, and any rate-limit/backoff behavior,
so deployment impact on latency and API quota can be monitored. If there is an
existing metrics or logging path in GitHubCollector, reuse it instead of adding
a new mechanism.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d892ed2-976b-49c0-b0ea-920acec30095

📥 Commits

Reviewing files that changed from the base of the PR and between 72a76b5 and 12cad7a.

📒 Files selected for processing (3)
  • backend/app/services/intelligence/github_collector.py
  • backend/tests/test_github_collector_extended.py
  • docs/adr/0016-github-skill-inference.md

エコシステム別キャップで 1 リポあたりの source fetch 件数が増えうるため、
GitHub API 消費量を監視できるよう fetch 件数(tree_blobs / manifest / source /
infra)を DEBUG ログに残す。既存の module logger を再利用し、レート制限・
バックオフは api_client 側の warning ログをそのまま流用する(重複させない)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend バックエンド documentation Improvements or additions to documentation test テスト追加・修正

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant