Skip to content

feat(ingest): index comments, PR reviews, inline comments (minor) - #107

Merged
liplus-lin-lay merged 1 commit into
mainfrom
106-ingest-comments-reviews
Apr 23, 2026
Merged

liplus-lin-lay merged 1 commit into
mainfrom
106-ingest-comments-reviews

Conversation

@liplus-lin-lay

Copy link
Copy Markdown
Member

目的

github-rag-mcp を Lin/Lay の記憶 DB として機能させるため、判断履歴の主要容器であるコメント系を ingest 対象に追加した。これまで issue/PR body + commit + release + docs しか入っておらず、コメント欄に残る判断履歴 (Master の指摘、AI 応答、セルフレビューの now/later/accepted 分類) が retrieval から欠落していた状態を解消する。

変更概要

新規 ingest 対象

イベント 新 type 値 内容
issue_comment (issues + PRs 共通の top-level) issue_comment comment body
pull_request_review (submitted / edited / dismissed) pr_review approve / request_changes / comment の body
pull_request_review_comment (created / edited / deleted) pr_review_comment 行単位のインライン diff comment

フィルタ

  • bot フィルタ: sender.login が [bot] で終わる場合は ingest しない (CI bot、dependabot、liplus-rag-mcp[bot] など)
  • 最小文字数: body.trim().length < 10 は skip (LGTM / +1 / 絵文字のみ等のノイズ排除)
  • webhook と poller 両方で同じ filter を適用

pipeline (src/pipeline.ts)

  • 新規 helper: isBotSender(login) / isBodyTooShort(body) / prepareCommentEmbeddingInput(author, body)
  • 新規 ingest 関数: ingestIssueComment / ingestPRReview / ingestPRReviewComment
  • embedding 入力 = {author}\n\n{body} で speaker 文脈を dense ベクトルに残す
  • bodyHash による変更検知 + 無変化 skip は既存 ingest と同パターン

webhook (src/webhook.ts)

  • eventType switch に 3 case 追加
  • deleted / dismissed では IssueStore + Vectorize + D1 FTS5 の 3 面から削除伝播

poller (src/poller.ts)

  • per-repo で最新 20 parent issue/PR について /issues/{N}/comments / /pulls/{N}/reviews / /pulls/{N}/comments を backfill
  • embedding 回数は per-repo 30 件で cap (Workers AI rate budget)

store (src/store.ts)

  • 新規テーブル: issue_comments / pr_reviews / pr_review_comments + 関連 index
  • 新規 endpoint: /upsert-comment / /comment / /recent-comments / 同 review / 同 review-comment
  • resetForReEmbed に 3 table も含める

search_issues (src/mcp.ts)

  • type enum に issue_comment / pr_review / pr_review_comment を追加
  • scan mode の aggregation loop に 3 type を追加 (既存 issue/PR/release/doc/diff のミラー)
  • search mode の URL 組み立てと title enrichment も 3 type に対応

docs

  • README.md / README.ja.md の type 表を新 3 値含む形に拡張
  • bot / min-length フィルタの挙動と PR review 検索の使用例を追記

テスト

  • npx tsc --noEmit pass
  • npx wrangler deploy --dry-run pass

リリース後の手動ステップ

merge 後、Master が GitHub App ダッシュボード (https://github.com/settings/apps/liplus-rag-mcp/permissions) の "Subscribe to events" で以下を有効化する必要あり:

  • Issue comment
  • Pull request review
  • Pull request review comment

poller の next tick で既存 comment は backfill される。webhook による realtime ingest は購読設定後から効く。

Closes #106

…r memory DB

判断履歴の主要容器であるコメント欄を ingest 対象に追加する。issue_comment /
pull_request_review / pull_request_review_comment を新 type として扱い、
bot (`sender.login` が `[bot]` で終わる) と trim 後 10 文字未満の body は ingest
時点で除外する。埋め込み入力は `author\n\n{body}` とし、speaker 文脈を dense
ベクトルに残す。search_issues の type enum に 3 値を追加し、scan mode も新規
recent endpoints を叩いて aggregation する。poller には per-repo 上位 20 parent
issue/PR について comments / reviews / review_comments を backfill する経路を
追加し、API fan-out と embedding 回数を別々に cap する。

Closes #106
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-rag-mcp a132925 Apr 23 2026, 11:36 AM

@liplus-lin-lay liplus-lin-lay left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

AI セルフレビュー (auto / minor)

Now — なし

Later

  • GitHub App "Subscribe to events" で Issue comment / Pull request review / Pull request review comment を有効化 (本 PR merge + Workers Build 自動 deploy 直後にブラウザから実施)
  • 判断記録: 記憶 DB 設計 (docs/f.-*.md) への固定化は merge 後に別 issue で
  • v0.9.0 release (human-gated)

Accepted

  • state 型を string に緩和 (review state APPROVED 等を受容) — 既存 FTS filter enum は据え置き、type filter で十分切り分け可能
  • bodyHash に author\n\nstate を title 代わりに使う (PR review) / author\n{path}:{line} (inline review comment) — state 変更 / 行移動を変更検知対象にする設計
  • MAX_COMMENTS_EMBEDDED_PER_REPO=30 を既存 MAX_EMBEDDINGS_PER_RUN=50 とは独立予算に — Workers AI rate budget を超えない安全側

検証項目

項目 結果
bot filter /\[bot\]$/ regex ✅ isBotSender helper、3 ingest 関数すべてで呼ばれる
10 文字未満スキップ ✅ isBodyTooShort helper + MIN_COMMENT_BODY_CHARS 定数
embedding input = {author}\n\n{body} ✅ prepareCommentEmbeddingInput
webhook 3 case 追加 (issue_comment / pull_request_review / pull_request_review_comment) ✅ switch 拡張 + 3 handler
削除伝播 (deleted / dismissed) ✅ IssueStore + Vectorize + FTS5 の 3 面
poller backfill (per-repo 20 parent / 30 comment cap) ✅ pollComments 新設
type enum 拡張 (3 値追加) ✅ zod + ScanRow + VectorMetadata
scan mode aggregation に 3 type 追加 ✅
IssueStore 3 新テーブル + 10 endpoint ✅
README / README.ja type 表分離 + 使用例 ✅
tsc --noEmit clean ✅
wrangler deploy --dry-run clean ✅
PR title ASCII / body 日本語 / Closes #106 ✅
CI 全 pass (test / CI / Workers Builds) ✅
mergeable ✅ CLEAN

判定

Approve — 記憶 DB (Lin/Lay 外部記憶) としての設計意図 (Master 2026-04-23) に沿い、permission と実装のギャップ (コメント読取不可) を閉じる構造変更。auto / minor のため AI merge で進める。merge 後に Workers Build auto deploy → GitHub App event subscribe flip の順で運用化。

@liplus-lin-lay
liplus-lin-lay merged commit 1edf74d into main Apr 23, 2026
3 checks passed
@liplus-lin-lay
liplus-lin-lay deleted the 106-ingest-comments-reviews branch April 23, 2026 11:38
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.

feat(ingest): index issue comments, PR reviews, PR inline comments for memory DB

1 participant