Skip to content

実装: overlap pagination の read-only runtime smoke を controlled VC として追加する #1610

Open

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1493"
goal_ref: "overlap preflight の GraphQL cursor pagination を read-only runtime smoke で検証できる controlled VC を提供する"
change_kind: workflow

Parent Issue

#1493

Parent Goal Ref

Current Validated Scope

Remaining Parent Gaps

Outcome

controlled runtime-smoke script と VC preflight policy が、read-only GraphQL pagination evidence を bounded に生成・検証でき、#1493 がその evidence を runtime AC の正規入力として使える状態。

In Scope

  • read-only GraphQL cursor pagination smoke の exact argv、repository binding、timeout、output/artifact bound を定義する。
  • VC preflight がその exact command だけを許可し、wrapper・extra flag・repository mismatch を拒否する。
  • smoke が page count、fetched count、terminal page、complete/saturated、route、skip reason を bounded JSON artifact に記録する。
  • pytest で allow/deny と artifact schema を検証する。

Out of Scope

Acceptance Criteria

  • AC1: canonical runtime-smoke argv だけが VC preflight で許可される。
  • AC2: wrapper、extra flag、wrong repo、write-capable gh option、unbounded artifact path は fail-closed で拒否される。
  • AC3: smoke artifact は repository、timestamp、fetched_count、page_count、has_next_page、complete、saturated、route、skip_reason を bounded schema で記録する。
  • AC4: GitHub API が利用可能な環境では read-only runtime smoke を実行し、利用不能時は明示的 SKIP を成功扱いにしない。

Runtime Verification Applicability

runtime_verification_applicability:
  decision: immediate
  reason: "実 GraphQL pagination と gh authentication を含むため、fixture test だけでは AC4 を証明できない。"
  applicable_acs: [AC4]
  execution_environment: "gh 認証済み Linux/WSL repository checkout"
  skip_conditions: "gh 未認証、network unavailable、rate limit"
  fallback_policy: "SKIP は PASS に変換しない。"
  artifact_requirements: "bounded runtime-smoke JSON artifact"

Verification Commands

# AC1
$ uv run --locked pytest scripts/agent-guards/tests/test_runtime_smoke_command_policy.py -q
# AC2
$ uv run --locked pytest scripts/agent-guards/tests/test_runtime_smoke_command_policy.py -q
# AC3
$ uv run --locked pytest scripts/ci/tests/test_overlap_pagination_runtime_smoke.py -q
# AC4
$ uv run --isolated --locked --no-default-groups python3 scripts/ci/overlap_pagination_runtime_smoke.py

Allowed Paths

  • scripts/agent-guards/skill_runtime_command_policy.py
  • scripts/agent-guards/tests/test_runtime_smoke_command_policy.py
  • scripts/ci/overlap_pagination_runtime_smoke.py
  • scripts/ci/tests/test_overlap_pagination_runtime_smoke.py
  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • Python
  • pytest
  • GitHub GraphQL API

Required Design References

  • docs/dev/runtime-verification-policy.md
  • .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
  • .claude/skills/implement-issue/scripts/check_implementation_overlap.py

Delivery Rule

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jul 18, 2026
  2. squne121 commented on Jul 18, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。

    方向性は妥当ですが、現状の #1610 は「controlled VC を追加した」という形式だけを満たし、#1493 の本番 pagination producer が正しく動くことを証明しない false green を作れる契約です。

    #1610 自体には現時点でコメントはありません。

    Blocker 1: runtime verification の構文契約に違反している

    #1610 は runtime_verification_applicability.decision: immediate としていますが、AC4 に必須の次のタグがありません。

    <!-- runtime-verification: true -->

    リポジトリの SSOT は、immediate なのにこのタグが一つもない場合を明示的に blocker としています。また、SKIP は exit 77、fallback は FAIL でなければなりません。

    修正要求

    - [ ] AC5: ... <!-- runtime-verification: true -->

    のように runtime 専用 AC を分離してください。unit test の AC と実環境 AC を同じ AC4 に混在させるべきではありません。


    Blocker 2: smoke が production producer を検証していない

    現在の本番コード check_implementation_overlap.py は依然として、

    gh issue list --limit N
    saturated = len(data) >= limit
    

    で候補を取得しています。

    一方、#1610 は新規の独立スクリプト、

    scripts/ci/overlap_pagination_runtime_smoke.py
    

    を追加し、#1493 の pagination producer 自体には触れないと宣言しています。

    この構造では次の状態が成立します。

    1. smoke script は正しく GraphQL pagination する。
    2. smoke artifact は complete=true を返す。
    3. unit test と runtime VC は PASS する。
    4. 本番 check_implementation_overlap.py は引き続き100件で saturation 停止する。

    つまり、検証対象と実装対象が別物です。

    修正要求

    次のどちらかに変更してください。

    独立した GraphQL 実装を smoke 側に複製する案は却下すべきです。pagination query、cursor invariant、safety cap が二重管理になります。

    また、#1610 は #1493 の production API が確定しないと実装できません。Machine-Readable Contract に少なくとも次が必要です。

    depends_on:
      - "#1493"

    または stacked PR の固定 base SHA を指定してください。


    Blocker 3: 親Issueの核心条件がACから消えている

    親 #1493 の runtime AC は、実リポジトリで次を要求しています。

    • fetched_count > 100
    • 複数ページ収集
    • complete=true
    • saturated=false
    • has_next_page=false

    実際の overlap route が安全であることは要求していません。

    しかし #1610 の AC4 は「GitHub API が利用可能なら smoke を実行する」としか規定していません。これでは候補が0件、1ページ、100件以下でも PASS できます。

    修正要求

    runtime AC を少なくとも次まで固定してください。

    - [ ] AC5: 実 repository に対する runtime smoke が exit 0 となり、
      `repository == "squne121/loop-protocol"`、
      `fetched_count > 100`、
      `page_count >= 2`、
      `has_next_page == false`、
      `complete == true`、
      `saturated == false` を満たす。
      route の値は closed set に属することだけを要求し、安全 route は要求しない。
      <!-- runtime-verification: true -->

    GitHub GraphQL connection は first または last に1〜100を指定し、pageInfo.hasNextPage と endCursor で次ページを取得するのが公式契約です。([GitHub Docs]1)


    Blocker 4: canonical argv と AC2 が矛盾している

    記載されている canonical command は次です。

    uv run --isolated --locked --no-default-groups python3 \
      scripts/ci/overlap_pagination_runtime_smoke.py

    しかし AC2 は以下を拒否するとしています。

    • wrong repo
    • unbounded artifact path
    • extra flag

    canonical command に --repo も artifact path も存在しないため、wrong repo や unbounded path を入力する経路自体がありません。

    設計をどちらかに決める必要があります。

    推奨: stdout artifact 方式

    uv run --isolated --locked --no-default-groups python3 \
      scripts/ci/overlap_pagination_runtime_smoke.py \
      --repo squne121/loop-protocol \
      --issue-number 1493
    • --repo と --issue-number は exact value。
    • 任意 output path は受け付けない。
    • bounded JSON を stdout に1件だけ出す。
    • test-runner が worktree-local artifacts/ に保存する。

    任意の --output を許可するより安全かつ単純です。リポジトリの runtime verification policy も、artifact 保存責務を test-runner に置いています。


    Blocker 5: worktree artifact 書き込みが current-head 検証と衝突する

    現行 baseline_vc_preflight.py の current-head mode は、実行前後の、

    git status --porcelain=v1 -z --untracked-files=all
    

    を確認し、実行後に untracked file が生成されると certification を失います。

    そのため smoke script 自身が worktree 内へ JSON artifact を作ると、正常な runtime evidence 生成なのに worktree_not_clean_after_execution で blocked になる可能性があります。

    修正要求

    • smoke script は JSON を stdout に出す。
    • artifact 永続化は test-runner 側で行う。
    • stderr は診断専用とし、JSONを混在させない。
    • stdout/stderr はそれぞれ byte cap を設ける。

    リポジトリ内の既存 controlled runner も、stdout/stderr をストリーミングしながら上限を監視し、timeoutまたは上限超過時に process group を終了しています。


    Blocker 6: policyの責務境界が混線している

    #1610 の Allowed Paths には、

    scripts/agent-guards/skill_runtime_command_policy.py
    .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
    

    の両方があります。

    しかし、この二つは別の admission layer です。

    • baseline_vc_preflight.py
      Issue本文の Verification Command を分類・実行する policy。
    • skill_runtime_command_policy.py
      preflight.run などの privileged exact command ID を認可する policy。

    現行 skill_runtime_command_policy.py に存在する command ID は preflight.run 系のみであり、新しい pagination smoke profile はありません。

    新しい privileged profile を追加するつもりなら、少なくとも executor、registry、runner wiring まで必要です。現在の Allowed Paths では完結しません。

    一方、単に Issue VC として runtime smoke を許可するだけなら、skill_runtime_command_policy.py は不要です。類似の exact uv smoke allowlist は既に baseline_vc_preflight.py に実装され、そのテストも issue-contract-review 配下にあります。

    推奨

    skill_runtime_command_policy.py と scripts/agent-guards/tests/test_runtime_smoke_command_policy.py をスコープから除外し、次へ寄せてください。

    .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
    .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py
    .claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py
    .claude/skills/issue-contract-review/references/vc-preflight.md
    

    Blocker 7: exact argv の過去の失敗を再発させる可能性が高い

    類似変更の #1195 / PR #1200 では、当初「exact runtime smoke」と称しながら、

    • Path(argv[0]).name
    • option の set 比較

    を使用していました。結果として path-qualified executable、option reorder、duplicate option を許す余地が残り、#1210 で exact list comparison に修正されています。

    #1610 の AC1に「canonical argvだけ」と書くだけでは不十分です。

    最低限、以下を negative test として列挙してください。

    /usr/bin/uv run ...
    ./uv run ...
    uv run --locked --isolated ...
    uv run --isolated --isolated --locked ...
    uv run ... /usr/bin/python3 ...
    uv run ... ./python3 ...
    uv run ... python ...
    uv run ... python3 ./scripts/ci/overlap_pagination_runtime_smoke.py
    env GH_REPO=other/repo uv run ...
    GH_HOST=example.com uv run ...
    bash -c 'uv run ...'
    sh scripts/wrapper.sh
    uv run ... smoke.py --repo other/repo
    uv run ... smoke.py --repo=squne121/loop-protocol
    uv run ... smoke.py --issue-number 1493 --extra
    

    raw argv の完全な tuple/list comparison を使用し、basename 比較、option集合比較、正規化後の同値判定で許可してはいけません。


    Blocker 8: 「read-only」の定義が弱い

    gh api graphql は、read query も mutation も同じ GraphQL endpoint に送信します。HTTP methodだけで read-only を判定できません。GraphQL では operation が query か mutation かが意味を決めます。([GitHub Docs]2)

    したがって、AC2 の「write-capable gh optionを拒否」だけでは不十分です。

    必要な固定条件

    • GraphQL document はコード内定数。
    • operation は名前付き query 一つのみ。
    • caller が query文字列や fields を渡せない。
    • mutation tokenを含む任意 query inputを受け付けない。
    • repository.issues connection を使用する。
    • states: OPEN と labels: ["phase/implementation"] を固定する。
    • issue number、title、bodyの全文を artifact に含めない。
    • subprocess は shell=False。
    • gh alias、extension、wrapperを使用しない。

    Repository.issues は after、first、labels、states、orderBy を正式にサポートしています。([GitHub Docs]3)

    さらに GH_HOST は接続先を、GH_REPO はrepository contextを変更できます。caller環境をそのまま継承したまま「repo binding済み」と主張できません。([GitHub CLI]4)

    既存の run_scope_rollup_preflight.py では GH_HOST、GH_REPO、GH_CONFIG_DIR、GH_PATH、pager/debug系環境変数を除去しています。
    同等の環境 sanitation を再利用するか、共有helperへ抽出すべきです。


    Major 1: pagination invariant が定義されていない

    次の不正応答を fail-closed にする契約が必要です。

    • hasNextPage=true なのに endCursor が null または空。
    • 前ページと同じ endCursor。
    • cursor の循環。
    • nodes が list ではない。
    • data.repository が null。
    • response に errors がある。
    • fetched issue number が重複する。
    • safety max page到達。
    • page取得途中の timeout。
    • response byte上限超過。

    既存の repository asset は hasNextPage=true なのに cursor が取れない場合や、最大ページ数到達時に incomplete として停止します。

    gh api --paginate を利用する場合、GraphQL query が $endCursor を受け取り、pageInfo を返す必要があります。また各ページは別々のJSONとして出力され、--slurp を付けると配列化されます。([GitHub CLI]5)

    この smoke では挙動を細かく検証する必要があるため、--paginate に全て任せるより、Python側の明示ループの方が監査しやすい設計です。


    Major 2: bounded の具体値がない

    「bounded」とだけ書かれており、次が未定義です。

    • page size
    • max pages
    • max fetched items
    • per-request timeout
    • overall timeout
    • stdout max bytes
    • stderr max bytes
    • artifact max bytes
    • diagnostic文字列の最大長

    推奨初期値は例えば次です。

    page_size: 100
    max_pages: 100
    max_fetched_items: 10000
    per_request_timeout_seconds: 30
    overall_timeout_seconds: 90
    stdout_max_bytes: 65536
    stderr_max_bytes: 65536
    artifact_max_bytes: 16384

    値そのものより、定数・artifact・test expectation が一つのSSOTから導かれることが重要です。


    Major 3: artifact schema が形式だけで、意味論がない

    最低限、schema名と cross-field invariant が必要です。

    {
      "schema": "OVERLAP_PAGINATION_RUNTIME_SMOKE_V1",
      "repository": "squne121/loop-protocol",
      "timestamp": "2026-07-18T00:00:00Z",
      "fetched_count": 157,
      "page_count": 2,
      "has_next_page": false,
      "complete": true,
      "saturated": false,
      "route": "human_review_required",
      "skip_reason": null
    }

    PASS時の不変条件:

    skip_reason == null
    fetched_count > 100
    page_count >= 2
    has_next_page == false
    complete == true
    saturated == false
    route in ROUTES
    

    SKIP時:

    exit == 77
    stdout first line starts with "SKIP:"
    complete == false
    skip_reason is non-empty
    

    FAIL時:

    exit == 1
    complete == false
    

    bool が Python上で int の subclassである点にも注意し、page_count=true を整数として受理しない schema test が必要です。


    Major 4: rate limit を return codeだけで分類できない

    GitHub GraphQL は rate-limit関連を GraphQL response の errors として返す場合があり、HTTPまたはCLIの終了状態だけで完全に分類できません。またserver timeoutでは 502/504 になり得ます。([GitHub Docs]6)

    分類を明示してください。

    • gh 未導入、未認証、network unavailable、rate limit exhausted
      → SKIP 77
    • malformed JSON、schema drift、cursor invariant違反、repository mismatch
      → FAIL 1
    • API途中失敗、overall timeout、output cap超過
      → 原則 FAIL 1
    • fallback/cached fixtureで成功
      → FAIL 1

    実行を開始できない環境と、開始後に検証が壊れた状態を同じ SKIP にしてはいけません。


    推奨する再構成

    Machine-Readable Contract

    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: "#1493"
    depends_on:
      - "#1493"
    goal_ref: "production overlap pagination path を実 GitHub API で検証する controlled VC を提供する"
    change_kind: workflow

    設計

    1. 実装: open-pr の overlap preflight hard gate に --limit 伝播を追加し repo 規模拡大による全面停止を解消する #1493 が production pagination implementation を確定する。
    2. smoke はその実装を直接呼び出す。
    3. smoke独自のGraphQL paginationロジックは持たない。
    4. stdout に bounded artifact JSONを出す。
    5. test-runner が artifact を保存する。
    6. baseline_vc_preflight.py は exact raw argv の一形式だけを許可する。

    推奨 canonical command

    uv run --isolated --locked --no-default-groups python3 scripts/ci/overlap_pagination_runtime_smoke.py --repo squne121/loop-protocol --issue-number 1493

    推奨 Allowed Paths

    .claude/skills/issue-contract-review/scripts/baseline_vc_preflight.py
    .claude/skills/issue-contract-review/scripts/tests/test_baseline_vc_preflight.py
    .claude/skills/issue-contract-review/tests/test_vc_format_and_command_policy.py
    .claude/skills/issue-contract-review/references/vc-preflight.md
    scripts/ci/overlap_pagination_runtime_smoke.py
    scripts/ci/tests/test_overlap_pagination_runtime_smoke.py
    

    production pagination APIとの接続に追加パスが必要なら、#1493完了後の実パスを明示的に加えてください。

    最終評価

    #1610 は必要な follow-up ですが、現状は以下の理由で implementation-ready ではありません。

    Issue本文を修正してから実装へ進めるべきです。GitHubへのコメント投稿・Issue更新は行っていません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions