[ドラフト縮小 1/7] リポジトリ選定シグナルを AnalyzedRepoSummary へ永続化 - #572
Conversation
ADR-0026 決定 4。収集層の RepoData は topics / package_declarations / infra_declarations を持つのに、キャッシュへ永続化される AnalyzedRepoSummary は 4 フィールドだけで、判別材料を永続化層で捨てていた。そのためドラフトの選定は 最終 push 日時と言語バイト数しか使えず、チュートリアルと実プロジェクトを 区別できない。 - AnalyzedRepoSummary に選定シグナルを追加(既定値付きで後方互換) topics / language_bytes_total / direct_dependency_count / ecosystem_count / has_infra - response_mapper が RepoData から詰め替える。GitHub API の追加呼び出しはしない - 旧形式キャッシュ(新キー無し)は build_draft_source が生 JSON のキー有無で 判別し、ADR-0018 と同じ 409 + 再連携導線へ倒す。1 件でも欠けたら旧形式扱いに して選定が移行済みリポジトリへ偏るのを防ぐ - 依存種別 "direct" の判定リテラルが 4 箇所に散っていたため、SSoT を skills/types.py の DEPENDENCY_KIND_DIRECT に置いて本差分の 2 箇所を移行 契約変更に伴い、旧形式 fixture を持つ既存テスト 3 ファイルを新形式へ更新した。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Warning Review limit reached
Next review available in:51 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughChangesRepository selection signals
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant RepoData
participant response_mapper
participant AnalyzedRepoSummary
participant resume_draft_context
participant DraftSource
RepoData->>response_mapper: repository metadata and declarations
response_mapper->>AnalyzedRepoSummary: derived selection signals
AnalyzedRepoSummary->>resume_draft_context: cached repository summary
resume_draft_context->>DraftSource: validated repository signals
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@backend/app/services/agent/resume_draft/context.py`:
- Around line 43-46: Replace _SELECTION_SIGNAL_KEY with an immutable set
containing all five required ADR-0026 signals: language_bytes_total, topics,
direct_dependency_count, ecosystem_count, and has_infra; update the repository
validation around _SELECTION_SIGNAL_KEY at
backend/app/services/agent/resume_draft/context.py lines 106-114 to reject
dictionaries missing any key and preserve the existing 409 path. Parameterize
the missing-key test at backend/tests/test_resume_draft_mapper.py lines 280-318
to cover each required signal.
🪄 Autofix (Beta)
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 0d873261-6e5d-4f36-bd70-9c8d999152ce
📒 Files selected for processing (9)
backend/app/schemas/github_link.pybackend/app/services/agent/resume_draft/context.pybackend/app/services/intelligence/response_mapper.pybackend/app/services/intelligence/skills/types.pybackend/tests/test_github_link.pybackend/tests/test_resume_draft_api.pybackend/tests/test_resume_draft_mapper.pybackend/tests/test_worker/test_resume_draft.pyweb/src/api/generated.ts
Uh oh!
There was an error while loading. Please reload this page.
CodeRabbit の指摘(PR #572)を反映する。 代表キー(language_bytes_total)1 つの存在確認では、一部のシグナルだけを持つ キャッシュが guard を通過してしまう。Pydantic が既定値で欠落を埋めるため、 不完全なデータのまま選定が走る。 - _SELECTION_SIGNAL_KEY を 5 キーの frozenset へ置き換え、issubset で全件必須にする - 欠落キーごとにテストを parametrize(5 ケース) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Closes#561
概要
ADR-0026 決定 4。収集層の
RepoDataは topics /package_declarations/infra_declarationsを保持しているのに、キャッシュへ永続化されるAnalyzedRepoSummaryは full_name / description / created_at / pushed_at の 4 フィールドだけだった。判別材料を永続化層で捨てているため、ドラフトの選定ロジックは最終 push 日時と言語バイト数しか使えず、チュートリアルと実プロジェクトを区別できない。本 PR は永続化層へ経路を通すところまで。選定ロジック自体の変更は #562 が担当する。
変更内容
1. 選定シグナルの追加(後方互換)
topicslist[str]RepoData.topicslanguage_bytes_totalintlanguagesの合計direct_dependency_countintpackage_declarationsのうちdirectのみecosystem_countintpackage_declarationsのエコシステム種別数has_infraboolinfra_declarationsの有無いずれも既定値を持つため、旧形式 JSON のパースは従来どおり通る。
GitHub API の追加呼び出しはしない — すべて連携実行時に
RepoDataが取得済みの値で、_to_repo_summaryは既存フィールドを参照するだけ。collector には触れていない。2. 旧形式キャッシュの判定(409 + 再連携導線)
スキーマ側は既定値で受理するが、シグナル無しでの選定は品質を担保できないため、
build_draft_sourceが生 JSON のキー有無で判別して 409 へ倒す。ADR-0018 が定めた「reposキー欠落」判定と同じ流儀(Pydantic 検証後は既定値と区別できないため生 JSON を見る)。1 件でもシグナル無しが混ざれば旧形式扱いにしている。部分的に許容すると、選定が「移行済みリポジトリだけ」に偏って本命を取りこぼすため。
ResumeDraftNoRepositoriesError(再連携では回復しない別導線)と取り違えていないことをテストで assert している。3. 依存種別
"direct"の SSoT 化response_mapperに定数を足すと同じ意味の比較が 4 箇所目になり、Rule of Three(.claude/rules/common/duplication.md)を超過するため、概念の定義元であるskills/types.pyにDEPENDENCY_KIND_DIRECTを置いて本差分の 2 箇所を移行した。github_collector.py:165/skills/aggregator.py:217に残る 2 箇所は差分範囲外のため本 PR では変更しない(特にaggregator.pyは mutmut スコープで TDD 手順が要る)。#562 以降で当該ファイルを触る回に併せる。テスト
新規 5 件:
RepoData→AnalyzedRepoSummaryへ写ること(dev 依存を厚みに数えないことを含む)DraftSourceまで伝播すること([ドラフト縮小 2/7] backend: ドラフトの選定順を「継続期間 × 実装量」へ変更しノイズ判定を付与 #562 / [ドラフト縮小 4/7] backend: 候補一覧 API と選択付きドラフト生成 #564 の入力)契約変更に伴い、旧形式 fixture を持つ既存テスト 3 ファイル(
test_resume_draft_mapper/test_resume_draft_api/test_worker/test_resume_draft)を新形式へ更新した。旧契約を固定化したテストは残していない。検証
make ci: passmake codegen-types実行済み。web/src/api/generated.tsの差分を同 PR に含む(ADR-0007)注意点
select_reposは従来どおり最終 push 日時が第 1 キーのまま([ドラフト縮小 2/7] backend: ドラフトの選定順を「継続期間 × 実装量」へ変更しノイズ判定を付与 #562 で変更)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation