Skip to content

fix(scope-rollup): GitHub inventory を完全 pagination 化 - #1643

Merged
squne121 merged 11 commits into
mainfrom
worktree-issue-1593-scope-rollup-run-github-inventory-pagina
Jul 19, 2026
Merged

squne121 merged 11 commits into
mainfrom
worktree-issue-1593-scope-rollup-run-github-inventory-pagina

Conversation

@squne121

@squne121 squne121 commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

この PR は scope-rollup の inventory 完全性契約を更新します。

Acceptance Criteria 達成状況(AC1-AC8)

AC 内容 状態 証跡
AC1 500 件超でも GraphQL cursor pagination が完全性を満たす場合のみ planner へ渡す 満たす test_inventory_over_500_pages_to_total_count_without_truncation PASS
AC2 partial error・malformed・cursor 停滞・count mismatch は fail-close 満たす test_partial_graphql_error_or_stalled_cursor_fails_before_planner PASS、test_inventory_total_count_mismatch_after_terminal_page_fails_closed PASS
AC3 transaction-wide budget が inventory + nested PR-files pages を合算する 満たす test_global_budget_counts_inventory_and_nested_pr_file_pages PASS。fix_delta で nested PR-files page の inventory_items 計上漏れ(P1-3)も修正済み
AC4 manifest が total count / page count / pagination complete / budget / sha256 を記録し、v3 marker/parser が同一 schema で検証する 満たす test_manifest_fields_recorded PASS。fix_delta で pr_files_completeness(P1-1: per-PR page/item/sha256)を追加
AC5 AC1-AC4 の成功系・fail-close 系を検証する新規 pytest 満たす tests/codex/test_scope_rollup_graphql_pagination_v3.py 4 tests + fix_delta で追加した 201 件・重複 path テスト
AC6 既存 parser regression が legacy v2 marker を引き続き受理する 満たす(下記「AC6 成功証跡」参照) .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py 20 tests PASS(legacy v2 受理 2 種 + marker_schema_version discriminator 4 種を含む)
AC7 docs/dev/hook-boundaries.md#12c が完全性契約と v2 互換境界を正確に記述する 満たす 12c 節に marker_schema_version discriminator の記述を追記済み(fix_delta)
AC8 tests/codex/test_run_scope_rollup_preflight.py の既存 regression が GraphQL transport で PASS する 満たす(fix_delta で対応) tests/codex/test_run_scope_rollup_preflight.py 16 tests 全 PASS(旧 gh issue/pr list fake dispatcher を gh api graphql fake へ全面更新)

fix_delta 対応状況(人間レビュー、PR #1643 issue comment)

P0(マージ条件)

  • P0-1(_paginate_pr_files() の累積バグ): 対応済み。各ページを paths = [...] で上書きしており、2 ページ目以降を取得すると 1 ページ目の内容が失われていました(changedFiles > 100 の PR で len(full_paths) が最終ページ分だけになり pr_files_pagination_incomplete で停止する実バグ)。トップレベル query の endCursor を保持していないため、既存 seed(1 ページ目)を再利用せず常にゼロから再取得する設計に変更し、extend で全ページを累積、重複 path を拒否、terminal page 後に len(unique_paths) == changedFiles を検証するようにしました。201 件を 100+100+1 ページで取得する直接テスト(実装本体を fake に差し替えない)を追加しています。
  • P0-2(既存 regression 7 件失敗): 対応済み。tests/codex/test_run_scope_rollup_preflight.py の fake dispatcher を gh api graphql transport に全面更新し、16 tests 全 PASS にしました。
  • P0-3(marker parser の silent downgrade): 対応済み。inputs.query_schema_version の有無だけで legacy 判定していた既存ロジックを、明示的な marker_schema_version discriminator に置き換えました。現行 runner は常に marker_schema_version: 3 を stamp し、parser はこの値が 3 の場合 inputs の内容に関わらず完全性契約を必須とします(inputs 全体を削除した marker も reject)。marker_schema_version フィールド自体が存在しない pre-実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 の legacy v2 マーカーは引き続き受理されます(Issue 実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 AC6 の要求と一致)。

P1(可能な範囲で対応)

  • P1-1(per-PR completeness 証跡): 対応済み。manifest に pr_files_completeness(pr_count_checked / page_count / item_count / pagination_complete / per_pr.<PR番号>.{changed_files, item_count, page_count, sha256})を追加しました。
  • P1-2(labels / closingIssuesReferences の 100 件超 truncation): 未対応。plan_issue_scope_rollup.py(planner)を確認したところ labels / closingIssuesReferences はどちらも一切参照されていません(未使用フィールド)。レビュー案の「安全境界が小さい方」(利用しないフィールドは query と completeness hash 対象から明示的に除外する)を正しく実装するには GraphQL query 自体からこれらのフィールドを削除し、_normalize_inventory_node() の必須フィールド検証・正規化 DTO 形状・plan_issue_scope_rollup.py が読む issues.json/prs.json の入力 schema を横断的に変更する必要があり、影響範囲が本 fix_delta の時間内では独立検証しきれないと判断しました。follow-up Issue での対応を推奨します(未使用フィールドである根拠: plan_issue_scope_rollup.py に labels / closingIssuesReferences の参照なし)。
  • P1-3(budget の nested files 未計上・テスト都合 fallback): 対応済み。_paginate_pr_files() が取得した nested PR file ノード数を budget.inventory_items に加算するようにし、_ensure_pr_files_complete() の TypeError 捕捉による budget 省略 fallback(本番安全契約の迂回経路)を削除しました。
  • P1-4(query の分割): 未対応。P0 対応を優先したため見送りました。現行の単一 inventory connection query は 1 ページあたり最大 100 PR × 100 labels/100 files/100 closingIssuesReferences を同時要求しており、GitHub 側の resource limit で partial error になるリスクは残っています。P1-2 の対応(未使用フィールドの除去)と合わせて follow-up Issue で検討することを推奨します。

Issue #1644 統合内容

人間オーナーの判断により、Issue #1644(scope-rollup GraphQL pagination テストの python-test-plan 登録)を別 PR に分けず、本 PR に統合実装しました。

  • .github/ci/python-test-plan.json の targets に tests/codex/test_scope_rollup_graphql_pagination_v3.py が正確に1回登録されていることを確認しました(既存 fix_delta で追加済み。重複・欠落なし)。
  • scripts/ci/tests/test_python_test_plan.py に test_real_plan_includes_scope_rollup_graphql_pagination_v3_exactly_once を追加し、当該 path の exact-one registration を regression として固定しました。
  • .claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py に test_generate_artifact_scope_rollup_graphql_pagination_is_covered を追加し、pytest_argv.count == 1、changed/collected が対象ファイルのみ、uncovered_changed_test_files が空、artifact generation が exit 0 であることを固定しました。
  • Issue 実装: scope-rollup GraphQL pagination テストを python-test plan へ登録する #1644 自体は本 PR のマージ後に人間が readback して close する運用とし、この PR からは gh issue mutation を行っていません(Refs #1644 として参照のみ)。

検証:

$ uv run --locked pytest scripts/ci/tests/test_python_test_plan.py -q
......................................................                   [100%]
54 passed in 0.25s

$ uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py -q
........................                                                 [100%]
24 passed in 0.08s

CI 失敗の解消

  • python-test(Ruff E501 2 件): 解消済み。現行 head の run_scope_rollup_preflight.py に 120 文字超の行は存在しません(rg -n '.{121,}' で 0 件、既に前 commit で整形済みでした)。
  • node-backed-hook-tests(tests/codex/test_scope_rollup_graphql_pagination_v3.py が ci test-selection で uncovered): 解消済み。.github/ci/python-test-plan.json の targets に当該ファイルを追加し、Issue 実装: scope-rollup GraphQL pagination テストを python-test plan へ登録する #1644 の内容を統合してこの登録を regression test で固定しました。

Checks

以下の Issue 契約 Verification Commands、および fix_delta で追加したテストを実行し、すべて成功しました。

  • uv run --locked pytest tests/codex/test_scope_rollup_graphql_pagination_v3.py -q — 4 件成功
  • uv run --locked pytest tests/codex/test_run_scope_rollup_preflight.py -q — 16 件成功、旧 fake dispatcher の GraphQL 対応含む
  • uv run --locked pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q — 20 件成功、legacy v2 受理 + marker_schema_version discriminator を検証
  • uv run --locked pytest .claude/skills/impl-review-loop/scripts/tests/ -q — 13 件成功
  • uv run --locked pytest scripts/agent-guards/tests -q — 1015 件成功、1 件 skip
  • uv run --locked pytest scripts/ci/tests/test_python_test_plan.py -q — 54 件成功(Issue 実装: scope-rollup GraphQL pagination テストを python-test plan へ登録する #1644 統合分含む)
  • uv run --locked pytest .claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py -q — 24 件成功(Issue 実装: scope-rollup GraphQL pagination テストを python-test plan へ登録する #1644 統合分含む)
  • rg -n "transaction-wide pagination budget" docs/dev/hook-boundaries.md — 12c 節に記載済みであることを確認した
  • rg -n '.{121,}' scripts/agent-guards/run_scope_rollup_preflight.py — 該当 0 件で E501 超過なしを確認した

Schema Change Applicability

この変更は producer と consumer が共有する機械可読契約に適用します。

  • decision: schema_change
  • reason: SCOPE_ROLLUP_RUN_RESULT_V1 の inventory manifest と ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1.inputs に、complete pagination と transaction budget の必須契約を追加するため。fix_delta で marker_schema_version フィールドと manifest.pr_files_completeness を追加。

Schema Consumer Inventory

consumer の更新対象と互換性判断を、以下の inventory に明示します。

変更対象 schema: SCOPE_ROLLUP_RUN_RESULT_V1 / ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1

before/after 差分:

# before
query_schema_version: 2
inputs:
  issue_count: int
  pr_count: int

# after
marker_schema_version: 3   # fix_delta (P0-3): 明示的なバージョン discriminator
query_schema_version: 3
inputs:
  query_schema_version: 3
  issues_completeness: {page_count: int, item_count: int, total_count: int, pagination_complete: true, sha256: string}
  pull_requests_completeness: {page_count: int, item_count: int, total_count: int, pagination_complete: true, sha256: string}
  transaction_budget: {page_count: int, response_bytes: int, inventory_items: int, max_transaction_pages: int, max_response_bytes: int, max_inventory_items: int, deadline_seconds: number}
# manifest (SCOPE_ROLLUP_RUN_RESULT_V1) にも fix_delta (P1-1) で追加:
#   pr_files_completeness: {pr_count_checked: int, page_count: int, item_count: int, pagination_complete: true, per_pr: {"<pr_number>": {changed_files, item_count, page_count, sha256}}}

Consumer 列挙(rg コマンド例と結果):

rg -n "SCOPE_ROLLUP_RUN_RESULT_V1|ISSUE_SCOPE_ROLLUP_RUN_RESULT_V1" 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
# producer: run_scope_rollup_preflight.py
# marker producer: scope-rollup-runner.md
# marker consumer: parse_scope_rollup_run_result.py

Consumer 更新状況:

Consumer ファイル 更新有無 備考
scripts/agent-guards/run_scope_rollup_preflight.py 更新済み manifest v3 + pr_files_completeness(fix_delta P1-1)を producer として生成
.claude/agents/scope-rollup-runner.md 更新済み marker inputs へ completeness / budget を転記。fix_delta で marker_schema_version: 3 を追加
.claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py 更新済み 必須完全性フィールドを reject-on-missing で検証。fix_delta で marker_schema_version discriminator を追加

Compatibility Decision(互換性判断)

fix_delta で修正: 当初「v2 marker は fail-close で拒否する breaking change」と記載していましたが、Issue #1593 AC6 は legacy v2 marker の受理維持を明示的に要求しており矛盾していました(人間レビュー P0-3 指摘)。実装・Issue の実態に合わせて以下の通り修正します。

  • change_type: additive_change(v3 completeness contract の追加。legacy v2 の受理は維持)
  • compatibility: backward_compatible
  • migration_required: no
  • migration_or_followup: N/A
  • reason: marker_schema_version フィールド自体が存在しない pre-実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 の legacy v2 marker は、Issue 実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 AC6 の要求通り引き続き受理される。現行 runner(.claude/agents/scope-rollup-runner.md)が生成する marker_schema_version: 3 マーカーのみ、v3 completeness contract を必須とする(inputs の内容に関わらず、フィールド欠落・型不正・未完了状態は fail-close で reject)。これにより v3 producer 由来のマーカーが inputs.query_schema_version の欠落だけを理由に legacy v2 と誤認されて受理される silent downgrade を防ぎつつ、真の legacy v2 marker の互換性は壊さない。

AC6 成功証跡

legacy v2 marker 受理(AC6 相当)を検証する既存/新規テストの実行結果:

$ uv run --locked pytest .claude/skills/impl-review-loop/tests/test_parse_scope_rollup_run_result.py -q
....................                                                     [100%]
20 passed in 0.89s

内訳(AC6 に直接関わるテスト):

  • test_ok_when_capture_sidecar_file_matches_assistant_output — marker_schema_version フィールドなし・legacy 形の inputs(query_schema_version なし)を持つマーカーが status: ok で受理されることを検証(既存、fix_delta でも維持)。
  • test_ok_when_marker_schema_version_2_explicit_legacy_without_completeness(fix_delta 追加)— 明示的な marker_schema_version: 2 マーカーが completeness contract なしで受理されることを検証。
  • test_rejected_when_marker_schema_version_3_has_no_inputs_block(fix_delta 追加)— marker_schema_version: 3 かつ inputs 欠落のマーカーが reject されることを検証(P0-3 の中核: silent downgrade 防止)。
  • test_rejected_when_marker_schema_version_3_strips_only_query_schema_version(fix_delta 追加)— marker_schema_version: 3 かつ inputs.query_schema_version だけを削除したマーカーが reject されることを検証(旧ロジックが誤って legacy 扱いしていた具体的な穴)。
  • test_rejected_when_marker_schema_version_unsupported(fix_delta 追加)— marker_schema_version が 2/3 以外の値のマーカーが reject されることを検証。
  • test_ok_when_marker_schema_version_3_has_full_completeness_contract(fix_delta 追加)— marker_schema_version: 3 かつ完全な completeness contract を持つマーカーが受理されることを検証(positive counterpart)。

Safety Claim Matrix

安全性主張は各行の検証証跡と後続 Issue に限定します。

Claim Implemented? Not controlled Evidence Follow-up
partial GraphQL response を planner 入力にしない yes GitHub connection の原子的 snapshot は保証しない AC2 pytest PASS #1580
inventory / nested files の page budget を合算する yes GitHub API の可用性・rate limit は制御しない AC3 pytest PASS(fix_delta で nested files page の計上漏れを修正) #1580
marker consumer が完全性契約なしを拒否する yes capture hook 自体の復旧は対象外 AC4 pytest PASS #1527
nested PR files pagination が全ページを正しく累積する yes GitHub 側の実データ整合性(重複 ID 等)は検証対象外 201 件 3 ページ直接テスト PASS(fix_delta) #1593
v3 marker の silent downgrade を防止する yes field 自体の削除攻撃(marker_schema_version ごと削除)までは防げない AC6 テスト群 PASS(fix_delta) #1593

Notes

以下は実装スコープと証跡の注記です。

Allowed Paths 遵守

fix_delta で編集したファイルはすべて元 PR の Allowed Paths 内です(Issue #1644 統合分は Scope Delta 参照)。

ファイル Allowed 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 該当
.github/ci/python-test-plan.json Allowed Paths に列挙なし(Issue #1644 を本 PR に統合、Scope Delta 参照)
scripts/ci/tests/test_python_test_plan.py Allowed Paths に列挙なし(Issue #1644 を本 PR に統合、Scope Delta 参照)
.claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py Allowed Paths に列挙なし(Issue #1644 を本 PR に統合、Scope Delta 参照)

Scope Delta(fix_delta 追加分・Issue #1644 統合)

Scope Collision(範囲衝突の確認)

Scope Collision (C1): related_issue=#1633, #1629, #1604, #1603, #1601, #1595, #1588, #1432, #1390, #1176, #420, #351, #237, #225, #213, #205, #1644; 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, .github/ci/python-test-plan.json, scripts/ci/tests/test_python_test_plan.py, .claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.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 が検証する契約を実装しない。#1644 は本 PR に人間オーナーの判断で統合実装したため、独立 PR としての衝突は発生しない。human_decision: #1593 は docs/dev/hook-boundaries.md の 12c 節だけを変更し、#1432/#1633 と並行実装してよい。#1644 は本 PR への統合実装を人間が承認した。edit_intent: specialized executor の inventory/PR-files complete pagination、manifest schema、scope-rollup-runner marker、parser validation、専用 pytest、既存 preflight fixture compatibility、12c の当該記述、および #1644 の python-test-plan registration + regression test だけを変更する。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(提供規則)

Notes for Reviewer(レビュアー向け注記)

@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1643 closed).

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Verdict: REQUEST_CHANGES

PR #1643 の current head 97f5b99496521e041bdfd8ab4e6696fbc1819625 を、Issue #1593 の live contract と照合しました。

  • AC1--AC5 と AC7 は独立実行で PASS です。
  • AC6 は legacy v2 fixture が inventory_completeness_contract_invalid に先行 reject され、7 failed, 8 passed でした。
  • current-head CI は python-test と node-backed-hook-tests が failure です。前者は Ruff E501 2件、後者は追加テストの ci test-selection uncovered です。
  • PR 本文に必須の受け入れ条件達成状況・Allowed Paths 遵守の節および AC6 成功証跡がありません。
  • canonical Allowed Paths review gate は scope-rollup guard により実行不能で、機械判定を完了できませんでした。

LOOP_VERDICT_V2

LOOP_VERDICT_V2:
  verdict: REQUEST_CHANGES
  reviewed_head_sha: "97f5b99496521e041bdfd8ab4e6696fbc1819625"
  merge_ready: false
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: BEHIND
  blockers:
    - "AC6 の legacy v2 parser regression が 7 failed, 8 passed であり、v2 fixture が inventory_completeness_contract_invalid に先行 reject される"
    - "CI python-test: run_scope_rollup_preflight.py:623,628 の Ruff E501"
    - "CI node-backed-hook-tests: tests/codex/test_scope_rollup_graphql_pagination_v3.py が ci test-selection で uncovered"
    - "allowed_paths_review_gate.py が #1593 scope-rollup guard に拒否され、canonical allowed-paths 判定が未完了"
  required_auto_actions:
    - kind: update_pr_body_hygiene
      executor: implementation-worker
      skill: open-pr.update_pr
      blocking_merge_ready: true
      mechanical: true
    - kind: update_branch
      executor: implementation-worker
      skill: implement-issue.update_branch
      blocking_merge_ready: true
      mechanical: true
      expected_head_sha: "97f5b99496521e041bdfd8ab4e6696fbc1819625"
  auto_fix_applied: []
  follow_up_issue_requests: []
  allowed_paths_gate:
    status: indeterminate
    changed_files_source: review_gate_execution_blocked_by_local_guard
    changed_files:
      - ".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"
  allowed_paths_gate_source: review_subagent

@squne121

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES — マージ不可。

確認対象は current head d48965a91179880b626559040abd97a0223af349。PR は Draft のまま、最新 CI run 3325 は failure で、python-test と node-backed-hook-tests が失敗しています。コード上にも CI 整備だけでは解決しないページング本体の欠陥があります。

マージブロッカー

P0-1. PR files のページングがページを累積せず、100ファイル超の PR は必ず失敗する

_paginate_pr_files() は最初に existing_paths をコピーしていますが、各ページで次の代入を行っています。

paths = [n["path"] for n in nodes]

extend() ではなく上書きなので、二ページ目以降を取得すると、それ以前のページが失われます。たとえば changedFiles == 101 なら、一ページ目の100件を二ページ目の1件で上書きし、最終的に len(full_paths) == 1 となって pr_files_pagination_incomplete で停止します。実質的に、本PRの主要要件である nested PR-files 完走経路が動作しません。

専用テストは nested files について「共有ページ上限を超えたら失敗する」ケースしか実行しておらず、実装本体による複数ページ成功を検証していません。既存テストも _paginate_pr_files 自体を fake に差し替えているため、この欠陥を検出できません。

必須修正

  • 全ページを空の accumulator に追加する。
  • path 重複を拒否する。
  • terminal page 後に len(unique_paths) == changedFiles を検証する。
  • 201件を 100 + 100 + 1 ページで取得し、planner が全201件を受け取る直接テストを追加する。
  • existing_paths を使うなら、トップレベル query の endCursor も DTO に保持して二ページ目から続行する。そうでなければ一ページ目から再取得して全件を再構成する。

P0-2. Issue #1593 の AC8 が未達で、最新 JUnit でも既存 regression が7件失敗している

Issue #1593 の AC8 は、既存 test_run_scope_rollup_preflight.py の fake dispatcher を GraphQL transport に更新し、既存 regression を network 不要で通すことを明示しています。

ところが current head の JUnit では、次の7件が失敗しています。

  • pagination truncation
  • total-count mismatch
  • PR-files pagination success
  • PR-files pagination failure
  • 全終了経路での cleanup
  • manifest fields
  • stdout/stderr separation

大半は既存 fake が gh issue/pr list しか扱わず、新しい gh api graphql を unexpected gh args として拒否しているためです。既存テストコードにも旧 transport が残っています。

[確認した current-head JUnit artifact](sandbox:/mnt/data/pr1643-current-junit.zip)

Issue #1644 は新規 test file の python-test-plan 登録を扱うだけで、既存 preflight fixtures の修正は明確に #1593 側の責務としています。したがって、#1644 を統合して test-selection を直しても python-test の7失敗は解消しません。


P0-3. marker parser が v3 completeness を削除した silent downgrade を受理する

parser は inputs.query_schema_version が存在する場合だけ v3 completeness contract を検証します。

if isinstance(inputs, dict) and "query_schema_version" in inputs:
    validate_v3(...)

したがって、v3 marker から次をまとめて削除すると、

  • query_schema_version
  • issues_completeness
  • pull_requests_completeness
  • transaction_budget

legacy v2 と誤認して後続処理へ進みます。コードコメントの「never silently downgrade」と実装が逆です。

さらに PR 本文は「version 2 marker を fail-close で拒否する breaking change」と記載していますが、Issue #1593 の AC6 と実装コメントは legacy v2 の受理維持を要求しています。互換性判断自体が一貫していません。

必須修正

  • marker 自体に明示的な marker_schema_version を設ける。
  • current runner の marker は常に v3 discriminator を必須とする。
  • legacy v2 は「フィールド欠落」ではなく、明示的な v2 discriminator、または信頼済み producer version との対応で識別する。
  • query_schema_version だけを削除した marker、および inputs 全体を削除した current-producer marker が reject されるテストを追加する。

High priority

P1-1. manifest が nested PR-files の完全性証跡を持っていない

トップレベル PR pagination 後に、nested files を補完して PR 配列の SHA-256 は再計算しています。しかし manifest に残るのは次だけです。

  • トップレベル PR connection の page_count
  • PR 件数の item_count / total_count
  • PR DTO 全体の SHA-256
  • transaction 全体の aggregate budget

各 PR-files connection の実測ページ数、changedFiles、取得ファイル数、terminal state、ファイル集合の hash は保存されていません。pagination_complete = True だけを再代入しているため、どの nested connection を何ページ処理して完全性を証明したかを consumer が独立検証できません。

Issue #1593 の AC4 が要求する「inventory / PR-files の total count、page count、pagination complete state、budget consumption、sha256」を満たすには、少なくとも次のような独立ブロックが必要です。

pr_files_completeness:
  pr_count_checked: 12
  page_count: 19
  item_count: 743
  pagination_complete: true
  per_pr:
    "1643":
      changed_files: 201
      item_count: 201
      page_count: 3
      sha256: "..."

P1-2. labels と closingIssuesReferences は100件で黙って切れる

トップレベル query は以下を取得しています。

labels(first: 100)
closingIssuesReferences(first: 100)

しかし pageInfo や totalCount を取得せず、追加ページも走査しません。これらを含めた normalized DTO の hash を「complete inventory」として記録するため、101件以上では切り詰められた DTO が完全として署名されます。

GitHub GraphQL の connection は一回の first / last が最大100件で、全件取得には cursor と hasNextPage による巡回が必要です。closingIssuesReferences も正式に IssueConnection と定義されています。([GitHub Docs]1)

対処は二択です。

  1. planner が実際に利用する nested connection を完全ページングする。
  2. planner が利用しないフィールドは query と completeness hash 対象から外し、「完全性の対象」を明示的に限定する。

後者の方が安全境界は小さくなります。


P1-3. transaction budget の item accounting が nested files を数えていない

_run_gh_graphql() の item_count は既定値ゼロです。トップレベル Issue / PR node は後から手動加算していますが、PR file node は加算されません。そのため manifest の inventory_items と max_inventory_items は nested files を含まない一方、説明上は transaction-wide inventory budget とされています。

また、既存テスト互換のために TypeError を捕捉し、budget なしで paginator を再実行する production fallback が入っています。テスト double の都合で本番安全契約を迂回する経路を作るべきではありません。既存 fixtures を更新し、この fallback は削除すべきです。


P1-4. GraphQL query が広すぎ、fail-close の可用性を不必要に落とす

一回の PR page で最大100 PRを取得し、それぞれについて最大100 labels、100 files、100 closing references を同時要求しています。GitHub は、多数の nested connection に大きな first を同時指定する query は resource limit に達し、partial results と error を返し得るため、ページサイズ縮小、query 分割、必要フィールド限定を推奨しています。([GitHub Docs]2)

errors が存在する response を fail-close している点自体は正しいです。GraphQL 仕様では data と errors が同時に返る partial response が許容されるため、この拒否は維持すべきです。 ([GraphQL Specification]3)

推奨構造は次です。

  • Issue inventory query
  • 軽量 PR inventory query
  • 必要な PR だけ files query
  • planner が本当に使用する場合だけ labels / closing references の独立 pagination

マージ条件

最低限、以下が必要です。

  1. _paginate_pr_files() の累積バグ修正と、実関数による複数ページ成功テスト。
  2. v3 marker の absence-based downgrade 廃止。
  3. tests/codex/test_run_scope_rollup_preflight.py を GraphQL fake transport に更新し、AC8 全件成功。
  4. nested PR-files manifest contract の追加、または Issue 実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する #1593 の AC4 を正確な契約へ再定義。
  5. labels / closingIssuesReferences の完全性境界を確定。
  6. python-test と node-backed-hook-tests の current-head success。
  7. PR 本文の v2 compatibility 判断を Issue と実装に一致させる。

現状の「専用4テストが成功」は、主要な正常系を fake で回避しており、完全 pagination のマージ証跡として不十分です。GitHub へのレビュー投稿・コメント追加は行っていません。

squne121 and others added 6 commits July 19, 2026 22:16
- P0-1: _paginate_pr_files() accumulated only the last GraphQL page
  (paths = [...]) instead of extending across pages, silently discarding
  earlier pages the moment a PR's nested files() connection required more
  than one page. Rewritten to always re-fetch the connection from scratch,
  extend across every page, reject duplicate paths, and verify the
  terminal page's item count against changedFiles.
- P0-2: tests/codex/test_run_scope_rollup_preflight.py's fake gh dispatcher
  only understood the legacy `gh issue/pr list` transport and rejected the
  current `gh api graphql` calls with "unexpected gh args". Rewritten to
  dispatch GraphQL-shaped fakes matching the real inventory connection and
  PR-files connection queries; added a direct (non-mocked) regression for
  the 100+100+1 page P0-1 fix and a duplicate-path rejection test.
- P0-3: parse_scope_rollup_run_result.py only enforced the v3 completeness
  contract when "query_schema_version" happened to still be present inside
  `inputs`, so a marker that stripped just that one key (or `inputs`
  entirely) was silently accepted as a legacy v2 marker even when it came
  from the current v3-speaking runner. Added an explicit, mandatory
  `marker_schema_version` discriminator (current runner always stamps 3)
  so completeness is enforced independent of what `inputs` does or does
  not contain, while explicit v2 and field-absent legacy markers keep
  their existing (Issue #1593 AC6) acceptance path.
- P1-1: added a `pr_files_completeness` manifest block recording per-PR
  page/item counts and sha256 for nested files() pagination.
- P1-3: removed the TypeError/budget compatibility fallback in
  _ensure_pr_files_complete (now always threads the budget through), and
  PR-files pages now count toward the transaction-wide budget's
  inventory_items.
- CI: registered tests/codex/test_scope_rollup_graphql_pagination_v3.py in
  .github/ci/python-test-plan.json (it was uncovered by the python-test
  lane, tripping node-backed-hook-tests' G1 gate).

P1-2 (labels/closingIssuesReferences first:100 truncation) and P1-4 (query
narrowing) are not addressed in this delta; see PR body for rationale and
follow-up recommendation.
#1593)

PR #1643 review P0-3 の parser 修正(marker_schema_version による明示的な
v3/v2 判定)を 12c 節の記述にも反映する。
Issue #1644 の内容を PR #1643 に統合し、tests/codex/test_scope_rollup_graphql_pagination_v3.py
の python-test-plan 登録が exact-one であることと、ci_test_selection/v1 artifact
generator がこのファイルを uncovered として誤検知しないことを regression test で固定する。

Refs #1644

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

判定

APPROVE — merge_ready: true

確認対象は current head 43c1ce1562433793260e51588605fe597a4193cd。

経緯

前回イテレーション(head 37a47692...)では、P0-1(_paginate_pr_files accumulator バグ)・P0-2(既存 regression の GraphQL fake transport 対応)・P0-3(marker parser の silent downgrade 修正)は解消済みと確認したが、.github/ci/python-test-plan.json の変更が Issue #1593 の Allowed Paths 外であり、かつ Issue #1593 自身の Scope Delta 節が当該作業を別 Issue(#1644)の責務としていたため allowed_paths_gate: fail_closed で REQUEST_CHANGES とした。

人間オーナーの判断により、Issue #1644 の内容(.github/ci/python-test-plan.json の exact-one registration、scripts/ci/tests/test_python_test_plan.py の回帰テスト、.claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py の test_generate_artifact_scope_rollup_graphql_pagination_is_covered)を本 PR に統合する方針で解決した。

今回の確認結果

  • gh pr view --json files で実差分10ファイルを確認し、Issue #1593 の Allowed Paths(7件)∪ Issue #1644 の Allowed Paths(3件)と完全一致(超過・欠落なし、リネームなし)。
  • .github/ci/python-test-plan.json の targets に対象テストが正確に1回のみ登録されていることを確認。
  • scripts/ci/tests/test_python_test_plan.py に exact-one-registration の回帰テストが追加され PASS。
  • .claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py に test_generate_artifact_scope_rollup_graphql_pagination_is_covered が追加され、Issue #1644 AC3 の assertion(pytest_argv.count==1、changed/collectedが対象のみ、uncovered空、rc==0)を固定して PASS。
  • docs/dev/hook-boundaries.md に transaction-wide pagination budget と marker_schema_version discriminator の記述を確認(AC7)。
  • .claude/skills/impl-review-loop/scripts/parse_scope_rollup_run_result.py で marker_schema_version == 3 の場合のみ completeness contract を必須化し、legacy v2(フィールド自体が存在しない marker)は従来通り受理する分岐を確認(Issue #1593 AC6 の互換要求と一致)。
  • CI 証跡(ci_verdict_summary.py --expected-head-sha 43c1ce15...): status: all_pass。python-test / node-backed-hook-tests を含む全 required check が head 一致で SUCCESS。
  • Mergeability: mergeable: MERGEABLE、mergeStateStatus: CLEAN。
  • Schema Consumer Inventory / Safety Claim Matrix は PR本文に存在し、consumer 更新状況・compatibility decision と整合。

allowed_paths_review_gate.py の直接実行は local guard の誤検知でブロックされたため、gh pr view --json files による実ファイル一覧の手動照合で代替した。今回の許可根拠は、Issue #1593 単独ではなく Issue #1644(当該3ファイルを Allowed Paths として明示する別の有効な OPEN Issue contract)+ PR本文の明示的な人間オーナー決定記録(Refs #1644)の組み合わせによる。Issue #1644 自体は、PR #1643 が main へ merge された後に人間が readback して close 判断する運用のため、意図的に close していない。

LOOP_VERDICT_V2

LOOP_VERDICT_V2:
  verdict: APPROVE
  reviewed_head_sha: "43c1ce1562433793260e51588605fe597a4193cd"
  merge_ready: true
  mergeability:
    mergeable: MERGEABLE
    merge_state_status: CLEAN
  blockers: []
  required_auto_actions: []
  auto_fix_applied: []
  follow_up_issue_requests: []
  allowed_paths_gate:
    status: ok
    changed_files_source: github_pull_request_files_api_with_previous_filename
    changed_files:
      - ".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"
      - ".claude/skills/pr-review-judge/scripts/tests/test_generate_ci_test_selection_fail_close.py"
      - ".github/ci/python-test-plan.json"
      - "docs/dev/hook-boundaries.md"
      - "scripts/agent-guards/run_scope_rollup_preflight.py"
      - "scripts/ci/tests/test_python_test_plan.py"
      - "tests/codex/test_run_scope_rollup_preflight.py"
      - "tests/codex/test_scope_rollup_graphql_pagination_v3.py"
    violations: []
    allowed_paths_source: "linked_issue_contract_union(#1593,#1644)"
  allowed_paths_gate_source: review_subagent

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.

実装: scope_rollup.run の GitHub inventory を完全 pagination で取得する

1 participant