feat(graph): opt-in GraphRAG layer over Decision Structure (D1 edges + traversal)#156
Merged
Conversation
Add an additive graph index over wiki Decision-Structure entries. A new D1 table (doc_edges, migration 0002) stores deterministic slug-mention edges between wiki pages; src/graph.ts extracts them at wiki index time (processAndUpsertWikiDoc) via exact slug matching (no LLM) and traverses them with a recursive CTE. The search tool gains opt-in graph_expand / graph_hops params: when off (default) retrieval is byte-identical to before; when on, related wiki pages are appended to results (graph_hop / graph_from). Delete fan-out (deleteEdgesForVector) and a one-off backfill endpoint (POST /admin/backfill-edges) are included. Requirements doc updated. dense(Vectorize)+sparse(D1 FTS5) のハイブリッドに、判断知(Decision Structure)の 関係を索引化する additive なグラフ層を足した。既定 off=既存 retrieval 完全不変、 on の時だけ関連 wiki を辿って末尾に付ける。エッジ抽出は決定的 slug-match で LLM 不要、再帰 CTE は実 SQLite で動作検証済み。評価は本番 ship 後の実運用観測。 Refs #155
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
github-rag-mcp | 6b9341f | Jun 14 2026, 04:52 AM |
liplus-lin-lay
commented
Jun 14, 2026
liplus-lin-lay
left a comment
Member
Author
There was a problem hiding this comment.
自己レビュー(auto モード / AI self-review)
整合・安全
- 完全 additive・既定 off:
graph_expand省略時、retrieval は dense+sparse+RRF の既存パスのみを通り byte-identical(graph 層は読まれない)。回帰リスクなし。 - 抽出フック / delete fan-out / backfill / graph 展開は全て try/catch の best-effort で、失敗しても本体 index・retrieval を壊さない。
- migration は
IF NOT EXISTS・追加テーブルのみ(既存スキーマ非破壊)。
検証
tsc --noEmitexit 0。- 再帰 CTE を実 SQLite(=D1 同エンジン)で実行検証済(seeds→1-2hop neighbor 正確・provenance 正確・repo フィルタ動作)。
- CI: test / CI / Workers Builds 全 pass、mergeStateStatus=CLEAN。
deploy(Master go 済み: 「実装して ship+実運用観測」)
merge 後: wrangler d1 migrations apply github-rag-fts → wrangler deploy → POST /admin/backfill-edges → observe(~5分/次 cron)。回帰確認(graph_expand 省略=不変) を最優先で実施。
判定: マージ可。
This was referenced Jun 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #155
概要
dense(Vectorize)+sparse(D1 FTS5) の RRF ハイブリッドに、判断知(Decision Structure = wiki エントリ)の関係を索引化する additive なグラフ層を追加。
searchに opt-in のgraph_expandを足し、関連 wiki ページを辿って結果末尾に append する。設計原則
graph_expand=false(既定)時は既存 retrieval と byte-identical(回帰なし)。on の時だけグラフを読む。wikiDocVectorIdで計算でき lookup 不要(dangling 可)。変更
migrations/0002_graph_edges.sql:doc_edgesテーブル(src/dst/repo/slugs/edge_kind)+index。src/graph.ts(新規): 抽出(indexWikiEdges)/ upsert / delete / 再帰CTE traversal(queryNeighbors)/ neighbor enrich。src/pipeline/embed-doc.ts: wiki index 直後に抽出フック(失敗しても本体 index を壊さない)。src/mcp.ts:searchにgraph_expand/graph_hopsparam、RRF 後の最終結果を seed に neighbor を append、ResultItemにgraph_hop/graph_from、response にgraph_expanded/graph_neighbors。src/poller.ts: wiki 削除時の edge delete fan-out。src/index.ts:POST /admin/backfill-edges?repo=...(GITHUB_TOKEN 認証)で既存 wiki から一括抽出(GitHub 再取得不要)。docs/0-requirements.{ja,}.md: graph 層の節を追記(同一 PR)。検証
tsc --noEmit通過(exit 0)。graph_expand省略時の回帰なし確認 → backfill 実行 → 実 DS クエリで on/off 比較を実運用観測(Li+ ネイティブ評価)。デプロイ(auto モード)
AI self-review → merge →
wrangler d1 migrations apply github-rag-fts→wrangler deploy→ backfill → observe(~5分/次 cron)。Master が "実装して ship+実運用観測" を go 済み。