Skip to content

refactor(pipeline): split pipeline.ts (1658 lines) into per-surface modules (patch)#154

Merged
liplus-lin-lay merged 1 commit into
mainfrom
147-refactorpipeline-split-pipelinets-1658-lines-into-per-surface-modules
May 25, 2026
Merged

refactor(pipeline): split pipeline.ts (1658 lines) into per-surface modules (patch)#154
liplus-lin-lay merged 1 commit into
mainfrom
147-refactorpipeline-split-pipelinets-1658-lines-into-per-surface-modules

Conversation

@liplus-lin-lay
Copy link
Copy Markdown
Member

目的

src/pipeline.ts (1658 行) を src/pipeline/ 配下の 10 モジュールに per-surface 分割し、 src/pipeline.ts 自体は 22 行のバレル (re-export only) に縮退。 consumer (src/poller.ts / src/webhook.ts) は import 文無変更で動作する。 読みやすさと修正局所性を上げ、 将来の surface 追加 (新 GitHub event 等) の影響範囲を限定する。

Closes #147

変更点

分割先 (src/pipeline/)

ファイル 行数 内容
ingest-filter.ts 33 MIN_COMMENT_BODY_CHARS, isBotSender, isBodyTooShort
embedding.ts 69 MAX_EMBEDDING_*, generateEmbedding, generateEmbeddingBatch
hash.ts 96 computeBodyHash, prepareEmbeddingInput, base64UrlEncode, sha256Hex, prepareDiffEmbeddingInput, prepareCommentEmbeddingInput
vector-id.ts 135 stableVectorId (private), base64UrlEncodeBytes (private), vectorId / releaseVectorId / docVectorId / wikiDocVectorId / diffVectorId / issueCommentVectorId / prReviewVectorId / prReviewCommentVectorId
types.ts 19 跨ぎ型 UpsertResult のみ
embed-issue.ts 281 GitHubIssueData, processAndUpsertIssue
embed-release.ts 168 GitHubReleaseData, processAndUpsertRelease
embed-doc.ts 219 processAndUpsertDoc, processAndUpsertWikiDoc
embed-diff.ts 309 GitHubCommitDetail, DiffUpsertResult, normaliseFileStatus (private), fetchCommitDetail, processAndUpsertCommitDiff
embed-comment.ts 416 GitHubCommentData / GitHubPRReviewData / GitHubPRReviewCommentData, CommentUpsertResult, ingestIssueComment / ingestPRReview / ingestPRReviewComment

バレル (src/pipeline.ts)

22 行に縮退。 10 個の export * 文と docstring のみ。

設計判断 (subagent → main 引き継ぎ)

  • base64UrlEncodeBytesvector-id.ts 内 private に配置 (唯一の call site)。 hash.ts の public base64UrlEncode (UTF-8 入力) とは別関数なので分離が自然
  • stableVectorId の NUL セパレーター (``) は byte-for-byte 保持済み。 Vectorize 既存 vector ID と完全一致するため re-index 不要 (node の生バイト確認: 34, 0, 34 = `"` + NUL + `"`)
  • UpsertResult のみ pipeline/types.ts に分離 (issue/release/doc/wiki が共有)。 DiffUpsertResult / CommentUpsertResult は owning module に同居

動作変更ゼロの検証

  • 全 export name 比較: main 40 個 → branch 40 個、 差分 0 (node で export (function|interface|const|type) 抽出して set diff)
  • src/poller.ts / src/webhook.ts の git diff = 0 lines (import 文不変)
  • tsc --noEmit clean、 wrangler deploy --dry-run 成功

AI 自己レビュー (auto モード)

分類

  • refactor 100%、 挙動変更ゼロ、 public surface 不変
  • consumer 側影響ゼロ、 vector ID 互換性保持
  • patch 維持

検証ゲート (subagent 報告 + main 再検証)

ゲート 結果
tsc --noEmit clean
wrangler deploy --dry-run 成功 (2228.62 KiB)
git diff main -- src/poller.ts src/webhook.ts 0 lines
src/pipeline.ts 行数 22 (target 30-60 内)
barrel 経由 import 残存 poller.ts:35 / webhook.ts:31 で ./pipeline.js import 維持
export name set 一致 main 40 ⇔ branch 40、 差分なし
stableVectorId NUL セパレーター 生バイト一致 (vector ID 互換)

CI pass を確認次第、 auto モード規約に従い gh pr merge --squash で直接マージする。

🤖 Generated with Claude Code

…odules (#147)

`src/pipeline.ts` (1658 行) を per-surface モジュール群 (`src/pipeline/*.ts`)
に分割し、 `src/pipeline.ts` 自体は全 export を再エクスポートするバレル (22 行)
に縮退させた。 これにより読みやすさと修正局所性が上がり、 将来の surface 追加
(例: 新 GitHub event タイプ) の影響範囲が一モジュールに限定される。

分割した新規ファイル:
- `pipeline/ingest-filter.ts` (33 行) — `MIN_COMMENT_BODY_CHARS`, `isBotSender`, `isBodyTooShort`
- `pipeline/embedding.ts` (69 行) — Workers AI BGE-M3 ラッパーとバッチ上限定数
- `pipeline/hash.ts` (96 行) — body hash, 各 surface 用 embedding input formatter, `base64UrlEncode`, `sha256Hex`
- `pipeline/vector-id.ts` (135 行) — `stableVectorId` (private), 全 surface の vector ID builder。 `base64UrlEncodeBytes` は唯一の呼び出し元である `stableVectorId` と同居させて local 化した
- `pipeline/types.ts` (19 行) — issue / release / doc / wiki で共有される `UpsertResult`
- `pipeline/embed-issue.ts` (281 行) — `GitHubIssueData`, `processAndUpsertIssue`
- `pipeline/embed-release.ts` (168 行) — `GitHubReleaseData`, `processAndUpsertRelease`
- `pipeline/embed-doc.ts` (219 行) — `processAndUpsertDoc`, `processAndUpsertWikiDoc`
- `pipeline/embed-diff.ts` (309 行) — `GitHubCommitDetail`, `DiffUpsertResult`, `normaliseFileStatus`, `fetchCommitDetail`, `processAndUpsertCommitDiff`
- `pipeline/embed-comment.ts` (416 行) — comment / review / review-comment の 3 surface (`ingestIssueComment`, `ingestPRReview`, `ingestPRReviewComment`) と関連型

consumer (`src/poller.ts` / `src/webhook.ts`) の import 文は無変更。
barrel が全 public symbol を再エクスポートするため backward-compat 保証。

動作変更なし。 関数本体・型シグネチャ・コメント・エラー文言は逐語的に移植。
`tsc --noEmit` clean、 `wrangler deploy --dry-run` 成功、 `git diff src/poller.ts src/webhook.ts` 差分ゼロを確認済み。

Closes #147

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@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 96bce22 May 25 2026, 01:21 AM

@liplus-lin-lay liplus-lin-lay added this to the v0.8.7 milestone May 25, 2026
Copy link
Copy Markdown
Member Author

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

Choose a reason for hiding this comment

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

AI self-review (auto mode)

分類確認

  • refactor 100%、 挙動変更ゼロ、 public surface 完全一致 (40 export ⇔ 40 export)
  • consumer (poller.ts / webhook.ts) git diff 0 lines、 import 文不変
  • stableVectorId の NUL セパレーター 生バイト一致確認済み (34, 0, 34 = " + NUL + ") → Vectorize vector ID 互換、 re-index 不要
  • patch 維持

brake 確認

  • L3 Task Layer (USER_REPO github-rag-mcp) スコープ、 Evolution_Initiator_Autonomy brake 2 (L1 Model Layer 限定) 不適用
  • parallel-subagent-eval (brake 1) は Evolution_Initiator path 限定なので user repo 内 auto モード refactor では適用外、 self-review + CI で gate

diff 自己確認

  • src/pipeline.ts 1658 → 22 行、 10 個の export * + docstring のみ
  • src/pipeline/ 配下に 10 新ファイル (ingest-filter / embedding / hash / vector-id / types / embed-issue / embed-release / embed-doc / embed-diff / embed-comment)
  • 各新ファイル先頭に role docstring 完備
  • import パスは ../types.js, ../fts.js, ./hash.js 等の相対パス、 .js 拡張子付与 (ESM moduleResolution: bundler 規約)

設計判断

  • base64UrlEncodeBytesvector-id.ts 内 private に配置 (唯一の call site、 cross-module 露出回避)
  • UpsertResult のみ pipeline/types.ts に切り出し (issue/release/doc/wiki 共有)、 DiffUpsertResult / CommentUpsertResult は owning module 同居
  • 依存 DAG: embedding → (none); hash → embedding; vector-id → (none); types → (none); embed-* → ../types, ../fts, ./hash, ./embedding, ./vector-id, ./types, plus embed-comment → ./ingest-filter。 循環なし

CI

  • test (tsc --noEmit + wrangler deploy --dry-run): pass (18s)
  • CI gate: pass (3s)
  • Workers Builds: pass

マージ判断

auto mode: AI 自己レビュー pass → AI 直マージ (gh pr merge --squash)。 v0.8.7 milestone 紐付け済み、 #148 と同じ release に乗る候補。

@liplus-lin-lay liplus-lin-lay merged commit 7b0aa6b into main May 25, 2026
3 checks passed
@liplus-lin-lay liplus-lin-lay deleted the 147-refactorpipeline-split-pipelinets-1658-lines-into-per-surface-modules branch May 25, 2026 01:25
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.

refactor(pipeline): split pipeline.ts (1658 lines) into per-surface modules

1 participant