Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "scope_rollup.run が GitHub Issue / Pull Request inventory を無条件の 500 件 cap で切り詰めず、GraphQL pagination・partial error・consumer contract を一貫して完全性検証できるようにする"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: impl-review-loop の scope-rollup preflight が、完全性を証明できる inventory だけを planner に渡し、件数増加で恒久停止しないようにする。
- Desired Destination:
scope_rollup.run、scope-rollup-runner、preparation parser が、完全性 manifest を同一スキーマで producer / consumer として検証する。
Current Validated Scope
scripts/agent-guards/run_scope_rollup_preflight.pyはMAX_ITEMS_PER_KIND = 500とgh issue/pr list --limit 501に依存し、501 件目を検出するとinventory_truncatedで停止する。_run_gh_graphql()は GraphQL response の top-levelerrorsを fail-close せず、dataがある partial response を_fetch_total_counts()と PR files pagination が受理し得る。- manifest の
total_count、page_count、max_items_cap、pagination complete state は scope-rollup-runner marker のinputsに写されず、parse_scope_rollup_run_result.pyもそれらを検証しない。 - PR files pagination は per-PR
MAX_PR_FILE_PAGESだけで制限され、Issue / Pull Request inventory pages と合算する transaction-wide budget がない。
Remaining Parent Gaps
scope_rollup.runをskill_runtime_exec.pyの canonical profile へ統合する設計判断は 調査: scope_rollup.run exact executor を registry SSOT 経路(skill_runtime_exec 相当)へ統合すべきか検討する #1580 の責務であり、本 Issue では変更しない。- SubagentStop capture hook の復旧は 実装: Codex の SubagentStop scope-rollup capture を復旧する #1527 の責務であり、本 Issue では変更しない。
- command registry の argv / placeholder 契約は 実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する #1579 の責務であり、本 Issue では変更しない。
Outcome
run_scope_rollup_preflight.py、scope-rollup-runner marker / parser、回帰テスト、および docs/dev/hook-boundaries.md が、Issue・Pull Request・nested PR files の GraphQL pagination 完全性、partial error、transaction-wide budget と consumer-bound manifest を一貫して fail-close 検証し、完全 inventory のみを planner に渡す状態。
In Scope
- Issue / Pull Request inventory を GraphQL cursor pagination で取得し、
hasNextPage: false、cursor progress、server-sidetotalCount一致、responseerrors不在を満たした場合だけ planner へ渡す。 - GraphQL partial error、malformed connection、cursor 不進行、page deadline / page budget 超過、count mismatch、または fetch failure では partial inventory を planner へ渡さず fail-close する。
- inventory pages と nested PR-files pages を合算した transaction-wide page / output budget を導入し、budget 超過では reason code を保持して fail-close する。
- manifest schema を更新し、Issue / Pull Request inventory の total count、page count、pagination complete state、budget consumption と PR-files pagination 結果を記録する。
- scope-rollup-runner の v3 marker と
parse_scope_rollup_run_result.pyを更新し、v3 manifest の必須完全性フィールドを producer / consumer 両側で同じ schema として検証する。既存 v2 marker は parser regression で受理を維持し、v3 completeness を v2 へ遡及適用しない。 - complete pagination、partial GraphQL error、cursor progress、global budget、nested PR-files pagination、v3 marker/parser contract、および既存 v2 marker 互換を検証する pytest と
docs/dev/hook-boundaries.md#12cを追加・更新する。 tests/codex/test_run_scope_rollup_preflight.pyの既存 fake dispatcher / fixture を GraphQL cursor pagination transport に整合させ、network不要の既存 preflight regression を維持する。
Out of Scope
skill_runtime_exec.pyへの統合、command registry、hook dispatch、SubagentStop capture の変更。- planner (
plan_issue_scope_rollup.py) の candidate 判定ロジック変更。 - GitHub API の partial response を成功扱いにする回避、上限値だけを増やす暫定回避、または完全性検証の削除。
- AGY / Serena evidence retrieval の変更(実装: AGY local_asset_research の targeted source evidence を fail-close で返す #1638 の責務)。
Acceptance Criteria
- AC1: Issue / Pull Request inventory が 500 件を超えても、GraphQL cursor pagination が
hasNextPage: false、cursor progress、totalCount一致、responseerrors不在を満たす場合に限り、完全な items を planner へ渡す。 - AC2: Issue / Pull Request inventory または nested PR files で GraphQL partial error、malformed response、cursor 不進行、page deadline / page budget 超過、count mismatch、取得失敗が発生した場合、planner を起動せず stable reason code で fail-close する。
- AC3: transaction-wide budget は Issue pages、Pull Request pages、nested PR-files pages を合算して enforce し、PR-files pagination の per-PR 上限だけでは全 transaction を無制限にしない。
- AC4: successful manifest は inventory / PR-files の total count、page count、pagination complete state、budget consumption、sha256 を記録し、v3 scope-rollup-runner marker と parser がそれらの必須完全性フィールドを同じ schema で producer / consumer として検証する。
- AC5: 新規 pytest が AC1–AC4 の成功系・fail-close 系を検証し、実装前 baseline では対象 test file が存在しないため VC が fail する。
- AC6: 既存 parser regression は legacy v2 marker を受理し続け、v3 completeness 必須化が v2 fixture を先行 reject しないことを検証する。
- AC7:
docs/dev/hook-boundaries.md#12cが complete GraphQL pagination、partial-error fail-close、transaction-wide budget、v3 marker/parser manifest contract と v2 互換境界を正確に記述する。 - AC8:
tests/codex/test_run_scope_rollup_preflight.pyの既存 fake dispatcher / fixture が GraphQL cursor pagination を再現し、pagination truncation、total count mismatch、PR-files pagination、cleanup、manifest fields、stdout/stderr separation の既存 regression を network不要で PASS させる。
Verification Commands
# AC1
$ uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py::test_inventory_over_500_pages_to_total_count_without_truncation -q
# AC2
$ uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py::test_partial_graphql_error_or_stalled_cursor_fails_before_planner -q
# AC3
$ uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py::test_global_budget_counts_inventory_and_nested_pr_file_pages -q
# AC4
$ uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py::test_marker_parser_rejects_manifest_missing_completeness_contract -q
# AC5
$ uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py -q
# AC6
# baseline-expect: fail
$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q
# AC7
# baseline-expect: fail
$ rg -n "transaction-wide pagination budget" docs/dev/hook-boundaries.md# AC8
$ uv run --locked pytest tests/codex/test_run_scope_rollup_preflight.py -qAllowed Paths
- scripts/agent-guards/run_scope_rollup_preflight.py
- .claude/agents/scope-rollup-runner.md
- .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py
- .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py
- tests/codex/test_scope_rollup_graphql_pagination_v3.py
- tests/codex/test_run_scope_rollup_preflight.py
- docs/dev/hook-boundaries.md
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
- complete pagination と response
errors検査を有界な deadline / output size / cursor-progress 検証と両立できない場合 - v3 completeness contract を fail-close にしつつ、legacy v2 marker の parser 互換を同じ consumer で維持できない場合
skill_runtime_exec.py、command registry、hook dispatch、capture hook、または planner candidate logic の変更が必要になった場合
Required Skills
- Python(pytest / JSON schema)
- GitHub GraphQL pagination
Required Design References
- docs/dev/hook-boundaries.md#12c
- docs/dev/agent-skill-boundaries.md
- docs/dev/workflow.md
Runtime Verification Applicability
decision: immediate
reason: "GraphQL response fixtures、cursor、budget、v3 marker/parser consumer と legacy v2 marker は pytest の fake transport / fixture で実行時に検証できる。"
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
- AC8
execution_environment:
cli_tools:
- python3
- uv
- pytest
auth_required: false
network_required: false
notes: "fake GraphQL transport と fixture を使用し、live GitHub API は実行しない。"
skip_conditions:
- "fake transport で pagination / consumer contract を再現できない場合は停止し、人間判断へ戻す"
fallback_policy:
fallback_success_is_pass: false
notes: "`gh issue/pr list --limit N+1`、partial data、manifest field 未検証、または v3 validation を回避する v2 downgrade を PASS としない。"
artifact_requirements:
- "pytest output for test_scope_rollup_graphql_pagination_v3.py"
- "pytest output for test_parse_scope_rollup_run_result.py"
- "fixture showing GraphQL partial errors and cursor progression"
- "marker/parser completeness-contract assertion output"Scope Delta(任意)
- Owner feedback により、complete pagination だけでなく GraphQL partial error、transaction-wide budget、manifest producer/consumer contract、nested PR-files pagination を同一 transaction の安全条件として追加する。
- v3 marker の completeness は必須化する一方、既存 v2 marker の parser regression を維持する。v2 fixture を v3 schema 不足だけで reject する変更は本 Issue の互換契約に反する。
- PR fix(scope-rollup): GitHub inventory を完全 pagination 化 #1643 current-head CI で既存 preflight fixture が旧
gh issue/pr listfake dispatcher により GraphQL transport を拒否する場合は、当該 fixture を本 Issue の専用 compatibility regression として修正する。実装: scope-rollup GraphQL pagination テストを python-test plan へ登録する #1644 の python-test-plan registration と CI evidence は別 Issue の責務とする。
Scope Collision
Scope Collision (C1): related_issue=#1633, #1629, #1604, #1603, #1601, #1595, #1588, #1432, #1429, #1390, #1176, #420, #351, #237, #225, #213, #205; overlapping_paths=.claude/agents/scope-rollup-runner.md, .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py, docs/dev/hook-boundaries.md, scripts/agent-guards/run_scope_rollup_preflight.py, tests/codex/test_scope_rollup_graphql_pagination_v3.py, tests/codex/test_run_scope_rollup_preflight.py. non_conflict_reason: #1601 は scope_rollup.run の runtime-exec sibling profile / command policy integration、#1633/#1629/#1604/#1603/#1595/#1429 は controlled mutation・snapshot・worktree・launcher policy、#1432/#237/#225/#213 は docs/hook の別契約、#1390/#1176/#420 は広い tests/scripts scope、#351 は human-interface finalizer であり、いずれも GraphQL partial error、cursor progression、transaction-wide pagination budget、complete manifest を marker/parser consumer が検証する契約を実装しない。human_decision: #1593 は docs/dev/hook-boundaries.md の 12c 節だけを変更し、#1432/#1633 と並行実装してよい。edit_intent: specialized executor の inventory/PR-files complete pagination、manifest schema、scope-rollup-runner marker、parser validation、専用 pytest、既存 preflight fixture compatibility、12c の当該記述だけを変更する。dependency_ordering: #1601 の profile integration と競合する current PR があれば profile / command-policy 変更を取り込まず、shared executor と runner docs の同一箇所を先行契約として re-read してから実装する。#1527 capture hook、#1579 registry、#1580 研究 scope は変更しない。
Delivery Rule
- 1 Issue = 1 PR とし、専用 worktree で実装して Draft PR を作成する。
- 実装: command_registry.py の scope_rollup.run argv テンプレートに --invocation-id/--requested-at を反映する #1579、調査: scope_rollup.run exact executor を registry SSOT 経路(skill_runtime_exec 相当)へ統合すべきか検討する #1580、実装: Codex の SubagentStop scope-rollup capture を復旧する #1527 の scope には変更を加えない。
Notes for Reviewer
- Anchor: 実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 (comment)
- 一次証跡:
MAX_ITEMS_PER_KIND = 500、_fetch_list()の--limit N+1、_run_gh_graphql()のerrors未検査、_run_transaction()の per-PR-only pagination cap、scope-rollup-runner / parser の manifest 完全性未検証を read-only で確認した。 - 決定論的修正として GraphQL complete-pagination と consumer-bound manifest contract を実装する。cap 値を増やす、prompt 注記、または partial data を success とする workaround は採用しない。
Activity
squne121 commentedon Jul 18, 2026
判定
REQUEST_CHANGES —
reframe_in_place。問題設定自体は正しいです。現行 worker は Issue・PR を
--limit 501で取得し、500件を超えるとinventory_truncatedで恒久停止するため、complete pagination への移行は必要です。ただし現行 #1593 の契約では、「全件取得を証明した」と誤判定する実装、実装前から緑になる検証、manifest 契約のドリフトを防げません。現状のまま実装フェーズへ進めるべきではありません。
マージブロッカー
P0-1. Verification Commands が実装前から PASS する
AC1~AC3 はすべて、現在すでに成功している同一コマンドです。
既存テストは「500件超なら停止する」「取得件数と
totalCountが違えば停止する」ことを確認していますが、501件以上を複数ページで正常取得するケース、cursor 不進行、途中ページの GraphQL error、実 page countは確認していません。既存 subprocess E2E も Issue・PR が0件の stub であり、pagination 経路を通りません。
ACごとに未実装時に失敗する node ID を指定すべきです。
# baseline-expect: fail uv run --locked pytest \ tests/codex/test_run_scope_rollup_preflight.py::test_issue_and_pr_inventory_paginates_past_500 \ -q少なくとも次を個別 AC にしてください。
hasNextPage: falseghstub による E2EP0-2.
hasNextPage:false + len == totalCountは整合した snapshot の証明ではないGitHub の公式契約は、connection を
firstまたはlastの1~100件で取得し、endCursorを次のafterに渡してhasNextPage:falseまで巡回する、というものです。([GitHub Docs]1)しかし #1593 は、巡回中に Issue や PR が作成・削除・更新された場合の整合性モデルを定義していません。例えば途中で1件削除され、別の1件が作成されれば、欠落と重複があっても最終件数だけは
totalCountと一致し得ます。これは公式 pagination 契約から導かれる設計上の推論であり、GitHub API が複数リクエスト全体に snapshot isolation を提供するという契約は確認できません。([GitHub Docs]1)「完全」の定義を次のいずれかに限定してください。
推奨: bounded convergence
node.idとnumberの重複を拒否id / number / updatedAtの digest を再取得inventory_changed_during_fetchで停止これを「ある時点の原子的 snapshot」ではなく、二回の連続走査で収束した inventoryとして契約化するのが正確です。
P0-3. GraphQL の部分成功を成功扱いする危険がある
現行
_run_gh_graphql()は、終了コードが0で JSON object なら返しており、top-level のerrorsを確認していません。GraphQL は
dataとerrorsを同時に返す部分成功を正式に許容します。また GitHub は、rate limit 超過時に HTTP 200 と error message を返す場合があり、resource limit 到達時には partial results と error を返すと明記しています。([GraphQL Specification]2)したがって各ページで、最低限以下を強制する必要があります。
加えて以下を拒否してください。
nodesが list ではないnullpageInfo.hasNextPageが bool ではないendCursorが空endCursorが前ページから進まないP0-4. 現在の timeout・byte cap は「各ページ単位」であり、transaction 全体は無制限
現在は各
ghsubprocess に30~60秒、stdout/stderr に8MBの上限があります。しかし complete pagination にすると、ページ数だけ timeout と出力量が積み上がります。さらに各 PR の files pagination も追加されるため、数百回の subprocess を許容し得ます。
#1580 の Required Safety Properties にも global deadline と process-tree cancellation が要求されています。
次を AC に昇格すべきです。
すべて monotonic clock に基づく共通 budgetとして扱い、各
_run_gh_graphql()には残時間だけを渡してください。GitHub 自身も、大量・深い GraphQL query では page size を小さくすることや query を分割することを推奨しています。([GitHub Docs]3)Issue の Stop Condition に「有界な deadline と両立できない場合」があるだけでは不十分です。上限値、reason code、テストを In Scope / AC に固定する必要があります。
P0-5. Allowed Paths が producer/consumer 契約を更新できない
worker は現在、manifest に以下を出力します。
query_schema_version: 2max_items_cap: 500page_count = ceil(item_count / 100)実際に観測した API ページ数ではない。
さらに runner の正本も
query_schema_version: 2とmax_items_cap: 500を固定記述しています。しかし #1593 の Allowed Paths に
.claude/agents/scope-rollup-runner.mdがありません。取得元が
gh issue/pr listの単一 JSON 配列から、複数 GraphQL page の正規化結果へ変わるため、少なくとも以下は契約変更です。したがって
QUERY_SCHEMA_VERSION = 3へ上げ、Allowed Paths に最低限次を追加してください。parser を変更しない場合でも、
SCOPE_ROLLUP_RUN_RESULT_V1の全 consumer inventory と「変更不要」の根拠が必要です。現時点で runner、preparation、capture hook、parser、parser tests が同 schema を参照しています。High priority
P1-1.
page_countと SHA-256 の意味を明確化する現行 docs は
ceil(item_count / 100)を「実測値」と呼んでいますが、これは計算値です。改修後は次の意味に固定してください。
page_count: 成功応答として実際に処理したページ数page_size: query に指定した件数item_count: unique normalized node 数total_count: consistency check で採用した server 値sha256: 正規化した DTO の canonical JSON hashGraphQL node をそのまま planner に渡すのではなく、既存
gh --jsonと同じ形へ明示的に変換する normalizer が必要です。特にlabels、files、closingIssuesReferencesは GraphQL connection と CLI JSON で形状が異なり得ます。P1-2. 「inventory 完全」の対象フィールドが不明
Issue/PR のトップレベル connection が完走しても、PR の
filesconnection は別 pagination です。現行 worker はchangedFilesと取得済み files 数が違う場合に個別 pagination しています。#1593 では次を明記してください。
複雑な nested connection をトップレベル query に詰め込むと、GitHub の node/resource limit に達して partial response になる危険があります。PR 一覧と PR files は現在どおり分離した方が安全です。([GitHub Docs]3)
P1-3. 依存状態が drift している
#1580 は #1579 の close と PR #1572 の解決後に base SHA を固定して再レビューする契約ですが、現在 #1579 は open、#1580 は
verdict: deferred・base_sha: nullのままです。一方、PR #1572 はすでに main の最新コミットとしてマージされています。
#1593 は worker 内の変更として独立実装できる可能性はありますが、少なくとも本文を次のように更新すべきです。
P1-4. reason code が粗く、失敗解析できない
現在は cap 超過も totalCount mismatch も
inventory_truncatedで、error result はmanifest: nullになります。少なくとも以下に分割してください。
diagnostic には raw cursor や response 全体を出さず、kind、page index、expected/observed count、cursor hash、elapsed milliseconds だけを bounded に残すのが妥当です。
推奨実装構造
各ページで以下の順に検証します。
errors不在hasNextPage:falseその後、明示的な DTO へ正規化し、必要なら consistency pass を行い、Issue と PR の両方が complete になった後だけ private artifact を生成して planner を実行します。
gh api --paginate自体も GraphQL pagination をサポートしますが、query に$endCursorとpageInfo { hasNextPage endCursor }が必要で、各ページは別 JSON object として出力されます。既存の page-level validation、global budget、reason code が必要なため、この安全境界では Python 側で cursor loop を所有する方が監査しやすいです。([GitHub CLI]4)改訂後の最低 AC
501件超成功
Issue・PR がそれぞれ複数ページあり、全 unique node が planner に渡る。
各 fail-close 経路
GraphQL errors、malformed response、null node、cursor stalled、duplicate、page limit、byte limit、deadline、totalCount mismatch では planner 未実行。
consistency model
二回走査の digest 一致、または同等の明文化された方式で途中変更を検出する。
manifest
実 page count、page size、unique item count、canonical SHA-256、
query_schema_version: 3を検証する。既存 nested pagination 回帰
101ファイル以上の PR files pagination がトップレベル pagination 導入後も動作する。
実 subprocess E2E
paginated
ghstub を使い、worker → planner → verifier → stdout schema まで検証する。consumer/docs 整合
runner、preparation、parser、capture contract、hook-boundaries の schema inventory を検証する。
結論
#1593 は必要な改善ですが、現在は「500件 cap を外す」ことだけに焦点が寄りすぎています。実際の安全上の核心は、次の4点です。
これらを Issue 本文、Allowed Paths、Acceptance Criteria、baseline-fail tests に反映するまでは No-Go です。
実装: マージ済み PR の pr_review.publish marker を限定 archive し preflight 阻害を防ぐ (…
実装: マージ済み PR の pr_review.publish marker を限定 archive し preflight 阻害を防ぐ (…
squne121 commentedon Jul 19, 2026
Refinement Loop: Human Escalation Required
The loop has terminated and requires human review. Cause: human judgment required
human_escalationhuman_judgment_requiredBlockers
squne121 commentedon Jul 19, 2026
Contract Review Result
squne121 commentedon Jul 19, 2026
Contract Review Result
squne121 commentedon Jul 19, 2026
Contract Review Result
squne121 commentedon Jul 19, 2026
#1429 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1432 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1633 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#205 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
5 remaining items
squne121 commentedon Jul 19, 2026
#962 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#966 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1390 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1588 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1595 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1601 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1604 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
squne121 commentedon Jul 19, 2026
#1629 との重複は、ユーザー承認済みの C1/non-conflict と判断します。
fix(scope-rollup): v2 marker compatibility を維持する (#1593)
style(scope-rollup): GraphQL query を整形する (#1593)
squne121 commentedon Jul 19, 2026
Contract Review Result
fix(scope-rollup): PR review P0-1/P0-2/P0-3 fix_delta (#1593)
docs: marker_schema_version discriminator を hook-boundaries.md 12c に追記 (
fix(scope-rollup): GitHub inventory を完全 pagination 化 (#1643)