[Bug]: graphify query prints a different answer on each run (BFS walks a set in hash order)

オープン 初心者向け
#5,109 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@rohit-jsfreaky がすでに取り組んでいます。

2026年11月9日 から。

  • #5112 @rohit-jsfreaky による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
search

調査の方向性

graphify/serve.py の _bfs を読み、その走査順が graphify query の出力とトークン予算にどう影響するかを追ってください。Issue の PYTHONHASHSEED ループで再現し、次に同じクエリを異なるシードで確認してください。実行ごとに出力と保持されるエッジが安定すれば完了です。Issue ではテストファイルは指定されていません。

索引モデルが issue の本文から書いたものです。

説明

Pre-flight checks
  • I have checked the Troubleshooting section in the README
What happened?

graphify query prints a different answer on every run, on the same graph. _bfs in graphify/serve.py walks each level as a set of node ids (frontier = set(start_nodes), for n in frontier:), so the EDGE lines come out in string-hash order, which Python randomizes per process. query is not in _HASHSEED_PINNED_COMMANDS, and the MCP server runs the same traversal in a long-running process, so nothing pins it. The order also decides which edges survive the token budget.

Distinct outputs over 10 runs (PYTHONHASHSEED 1 to 10):

repo query budget distinct outputs
flask how does url_for work 50k 10
click how does echo work 50k 10
django how does slugify work default 10
django how does the queryset build sql 50k 10

On a FastAPI template repo, graphify query 'how does cn() work' run 6 times gave 5 different outputs.

Steps to reproduce
cd flask && graphify update .
for s in 1 2 3; do PYTHONHASHSEED=$s graphify query "how does url_for work" --budget 50000 | md5sum; done

Three different hashes.

Error output or graph output

Example, first 3 contains EDGE lines on a tiny graph (one seed, 60 neighbours), seeds 1 / 2 / 3:

helper_7, helper_17, helper_6 | helper_1, helper_13, helper_17 | helper_18, helper_17, helper_8
Graphify version

0.9.105 (v8 at 5eedffa8)

Operating System

Windows (also seen on Linux)

Python Version

3.12

Installation Method

uv tool install (recommended)

Additional context

_dfs uses a list stack and is already stable. Related but different: #2817 and #1667 (cluster order), #3743 (hash seed pinned for other commands).

主要言語
Python
スター
124k
フォーク
11.9k
平均マージ
2時間 35分
マージ済み PR(30日)
6

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Graphify-Labs/graphify のほかの issue

Graphify-Labs/graphify の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。