Skip to content

CI python-test pytest実行phase高速化: test lane分類・pytest統合・Ruff導入・Skill化 #1059

Closed
7 of 7 issues completed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: parent
goal_ref: "CI python-test の直列構造を解消し、test lane を分離・pytest を統合・Ruff を導入・ci-test-performance Skill を追加することで、AI エージェントが CI 高速化判断を再現可能に実行できる状態にする"
change_kind: ci-optimization
parent_mode: delivery-rollup
closure_mode: child-complete

Summary

CI の python-test job が直列構造で遅い。pytest を何度も起動し pnpm を不要にセットアップしている問題を解消する。また、テスト高速化の判断をエージェントスキルとして永続化し、今後の AI エージェント運用でも同じ判断を再現可能にする。

Goal

docs/dev/test-lane-policy.md と .claude/skills/ci-test-performance/SKILL.md が追加され、python-test job に 4 レーン分類ポリシー(fast-static / python-unit / contract-artifact / integration)が導入され、CI の Python test の wall-clock が短縮したことが ci_runtime_baseline_v1 artifact の比較で確認できる状態になること。

Outcome

全 child issue (#1060/#1061/#1063/#1064) がマージ済みとなり、python-test CI job が pnpm セットアップ不要・Ruff fast-static 検査付き・pytest 統合 invocation(pytest-xdist)で動作し、ci_runtime_baseline_v1 の before/after 比較で python-test job 内の pytest 実行 phase(pytest_parallel_ms + pytest_serial_ms) の wall-clock 短縮が確認できる状態になること。

  • 本 Outcome は 実装: pytest target plan を SSOT 化し serial→xdist 段階移行と ci_test_selection fail-close 化を行う(python-test 並列化 migration) #1064 の既存実装(pytest 部分時間のみ計測)と整合させるため、pytest 実行 phase のスコープに明確化する(OWNER anchor comment P0-2 の案A採用)。
  • python-test job 全体(Node.js セットアップ / Codex CLI 導入 / Codex 実行 / 別 pytest invocation 等を含む区間)の wall-clock 短縮は本 Outcome のスコープ外であり、Remaining Parent Gaps に follow-up 候補として記録する。
  • タイトルは pytest 実行 phase のスコープを厳密に反映していないが、title の変更は edit-issue の title_update(別 routing、本更新のスコープ外)で扱う。

Desired Destination

  • docs/dev/test-lane-policy.md: 4 lane 分類ポリシーと lane 判断マトリクスが docs 化される
  • .claude/skills/ci-test-performance/SKILL.md: AI エージェントが CI runtime artifact を読んで hotspot 分類・高速化判断を再現可能に実行できる
  • .github/workflows/ci.yml: python-test が pnpm セットアップ不要・pytest 統合・Ruff fast-static lane 付きの構造になる
  • pyproject.toml / uv.lock: ruff と pytest-xdist が dev dependency に追加される
  • .github/ci/python-test-plan.json: pytest 実行対象・--ignore/--deselect・worker 数・scheduler を集約する SSOT として存在する
  • ci_test_selection/v1 artifact: 実際の pytest 実行対象と artifact の pytest_args が一致する(schemas/tests/ の artifact 登録漏れ解消)

Current Validated Scope

ChatGPT による事前分析(2026-06-21)で確認済みの問題点:

  • python-test は setup-node-pnpm + pnpm install を実行するが Python test lane では pnpm 不使用
  • pytest が 10 回以上の step に分割され uv run / collection の固定費を毎回払っている
  • ci_test_selection/v1 の pytest_args と実際の pytest 実行対象がズレている(schemas/tests/ は既に CI で実行されているが artifact 登録が漏れている)
  • pytest-xdist は未導入
  • Python 静的検査に Ruff(Rust 製、10〜100倍高速)を使っていない

Decisions Fixed

  • 2026-06-21: pytest の全面置換はしない。pytest に載せる必要がない静的チェックを分離するアプローチを採用
  • 2026-06-21: python-test から pnpm セットアップを削除する(Python test lane では pnpm 不使用のため)
  • 2026-06-21: Ruff を pytest 前段の fast fail-fast gate として導入する
  • 2026-06-21: テスト高速化判断を .claude/skills/ci-test-performance/SKILL.md としてエージェントスキル化する
  • 2026-06-21: 「4 lane 設計」は物理 job/step 分離ではなく分類ポリシー導入。workflow 上では Ruff fast-static step と pytest unified step に反映する
  • 2026-07-25: OWNER anchor comment(REQUEST_CHANGES、下記参照)を受け、AC2 のスコープを「pytest 実行 phase」に限定する案A を採用する(既存実装 実装: pytest target plan を SSOT 化し serial→xdist 段階移行と ci_test_selection fail-close 化を行う(python-test 並列化 migration) #1064/PR 実装: python-test を pytest-xdist 並列化(plan SSOT / serial 統合 / generator fail-close)(#1064) #1151 が pytest 部分時間のみ実装しているため、案B の job 全体計測は follow-up 候補として別途記録する)
  • 2026-07-25: 親 AC1 の Closure Rule を、child issue の state/closedAt のみの検証から「merged PR / merge commit ancestry / required paths 存在」を組み合わせた検証へ強化する

Quality Decision Record

Parent Closure Rule

  • delivery-rollup: 以下の全 child issue が、単なる state: CLOSED ではなく次の 5 条件をすべて満たしたとき close する(child issue の state/closedAt のみによる判定は不可)
    1. Issue を close した PR が merged == true であること
    2. その PR の merge commit が現行 main の ancestor であること
    3. child ごとの required paths が現行 main に存在すること
    4. 可能な範囲で child の最終 AC を現行 main に対して再検証し、drift がないこと
    5. Issue の close reason が completed であること(not_planned 等は false positive として除外する。系譜内の実例: 実装: .claude/agents/implementation-worker.md / pr-reviewer.md / test-runner.md に ci-test-performance routing 契約を追記する #1097 は not_planned でクローズされている)
child_delivery:
  - issue: 1060
    merged_pr: 1078
    required_paths:
      - docs/dev/test-lane-policy.md
      - .claude/skills/ci-test-performance/SKILL.md
  - issue: 1061
    merged_pr: 1121
    required_paths:
      - .github/workflows/ci.yml
      - docs/dev/ci-performance.md
  - issue: 1063
    merged_pr: 1129
    required_paths:
      - pyproject.toml
  - issue: 1064
    merged_pr: 1151
    required_paths:
      - .github/ci/python-test-plan.json
      - .github/workflows/ci.yml

Child Issues

Remaining Parent Gaps

  • CI runtime baseline の定量比較(wall-clock before/after)は最終 child PR 時点で実施
  • ci_runtime_baseline_v1 artifact の集約方式変更(並列化対応)は child 4 の scope に含める
  • 将来的な ripgrep prefilter + Python verifier 分離は本 parent の scope 外
  • [follow-up 候補・未起票] python_test_job_total_ms(Node.js セットアップ〜Codex CLI 導入〜Codex 実行〜追加 pytest invocation を含む区間の wall-clock、同一 runner cohort で base/head 各20 run 比較)の計測・比較は本 parent の AC2 スコープ外。OWNER anchor comment の案B相当。別 Issue 化を検討する
  • OWNER anchor comment(https://github.com/squne121/loop-protocol/issues/1059#issuecomment-5078655505)に記載された non-blocking hardening 項目(P1/P2、いずれも本 parent の AC 化は不要だが記録として残す):
    • python-test job への Node/Codex 関連ステップ再混入により「Python-only lane」設計境界が事実上崩れている可能性(P0-3 相当、hardening 扱い)
    • 全 Python test file を漏れなく分類する inventory gate の欠如(新規 test file が plan 未登録のまま長期間 CI 対象外になり得る)
    • ignore/deselect が Issue 番号・owner・期限なしの恒久 quarantine になり得る
    • python_test_plan の一部フィールド(secondary_coverage 等)が fail-closed 検証対象外
    • Ruff 設定が pyproject.toml と workflow CLI オプションに分散し SSOT でない
    • ci_runtime_baseline_v1 artifact の upload が if-no-files-found: warn(親 AC2 必須証跡としては fail-open)
    • pytest scheduler(loadscope)選定根拠のベンチマーク cohort が GitHub-hosted runner 上で完結していない
    • benchmark-sensitive workflow の Action 参照が major tag 固定であり、full commit SHA pinning ではない(fact-check 済み: SHA pinning は GitHub が repository 単位で任意に有効化できる推奨設定であり、全リポジトリへの全面的な強制ポリシーではない)
    • 実装: python-test を pytest-xdist 並列化(plan SSOT / serial 統合 / generator fail-close)(#1064) #1151(self-authored PR、review subagent 不使用)の独立レビュー証跡が相対的に弱い

Phase Handoff Contract

  • Desired Destination: 上記参照
  • Current Validated Scope: 上記参照
  • Remaining Parent Gaps: 上記参照
  • Allowed Paths: child issue ごとに個別指定(本 parent は paths を持たない)
  • Required Skills: GitHub Actions YAML / Python packaging (pyproject.toml / uv) / Ruff / pytest-xdist
  • Stop Conditions: 標準 6 項目(各 child に記載)
  • Next Action: OWNER anchor comment の P0 blocker(Closure Rule 強化・AC2 スコープ明確化)解消状況を確認してから close 判定を再実施する

Allowed Paths

本 parent issue は Allowed Paths を持たない。各 child issue ごとに個別指定する。

Acceptance Criteria

Verification Commands

AC1 の検証は (a)(b)(d) 「merged / merge commit ancestry / close reason」と (c) 「required paths 存在」の 2 グループに分け、各コマンドは単一 shell 呼び出しに限定する(&& 等の compound shell operator は使わない)。

# AC1
# baseline-expect: pass
$ gh api graphql -F n=1060 -f query='query($n:Int!){repository(owner:"squne121",name:"loop-protocol"){issue(number:$n){stateReason closedByPullRequestsReferences(first:5){nodes{number merged mergeCommit{oid}}}}}}'
# baseline-expect: pass
$ gh api graphql -F n=1061 -f query='query($n:Int!){repository(owner:"squne121",name:"loop-protocol"){issue(number:$n){stateReason closedByPullRequestsReferences(first:5){nodes{number merged mergeCommit{oid}}}}}}'
# baseline-expect: pass
$ gh api graphql -F n=1063 -f query='query($n:Int!){repository(owner:"squne121",name:"loop-protocol"){issue(number:$n){stateReason closedByPullRequestsReferences(first:5){nodes{number merged mergeCommit{oid}}}}}}'
# baseline-expect: pass
$ gh api graphql -F n=1064 -f query='query($n:Int!){repository(owner:"squne121",name:"loop-protocol"){issue(number:$n){stateReason closedByPullRequestsReferences(first:5){nodes{number merged mergeCommit{oid}}}}}}'
# baseline-expect: pass
$ git merge-base --is-ancestor 7b8167774a16d5506dbb88670f3b68b75b22053a HEAD
# baseline-expect: pass
$ git merge-base --is-ancestor db86c058f2c18d4c9abeb06f074ed814fcfc44ec HEAD
# baseline-expect: pass
$ git merge-base --is-ancestor f2ee8f662add514fe531fcc1a2bad81405c62f97 HEAD
# baseline-expect: pass
$ git merge-base --is-ancestor 54858e277144d670eb2b24a1f96d82515f295c87 HEAD
# baseline-expect: pass
$ test -f docs/dev/test-lane-policy.md
# baseline-expect: pass
$ test -f .claude/skills/ci-test-performance/SKILL.md
# baseline-expect: pass
$ test -f .github/workflows/ci.yml
# baseline-expect: pass
$ test -f docs/dev/ci-performance.md
# baseline-expect: pass
$ test -f pyproject.toml
# baseline-expect: pass
$ test -f .github/ci/python-test-plan.json

# AC2
# baseline-expect: pass
$ gh issue view 1064 --repo squne121/loop-protocol --json closedAt --jq '.closedAt'

# AC3
# baseline-expect: pass
$ pnpm typecheck
# baseline-expect: pass
$ pnpm test
# baseline-expect: pass
$ pnpm build

Notes

Sub-issues

Sub-issues

7 of 7 Issues completed
Loading 7 sub-issues

Activity

  1. added
    tracking
    on Jun 20, 2026
  2. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    結論

    #1059 は方向性としては妥当です。python-test の Node/pnpm セットアップ削除、Ruff の fast-fail 導入、pytest 起動回数削減、ci_test_selection の証跡整合は、いずれも CI 高速化として筋が通っています。

    ただし、このまま Claude Code / Codex CLI に実装させるのは危険です。Issue 本文と child issue の検証コマンド・Allowed Paths・既存 docs が食い違っており、実装後に「CI は変わったが baseline 証跡・artifact 契約・docs が嘘になる」リスクが高いです。

    #1059 は open の parent tracker で、コメントは空です。materialize 済みの child は #1060 / #1061 / #1063 / #1064 の 4 件で、いずれも parent_issue "1059" を持つ implementation issue です。#1059 系および child issue 側のコメントも空でした。

    敵対的レビュー指摘

    1. schemas/tests/ は「実行漏れ」ではなく「artifact 登録漏れ」

    #1059/#1064 は ci_test_selection/v1 の pytest_args に schemas/tests/ が未登録だと述べています。これは正しいです。ただし、現行 python-test は既に pytest schemas (timed) として uv run --locked pytest schemas/tests/ -q を実行しています。つまり問題は「CI が schemas/tests を実行していない」ではなく、実行対象と ci_test_selection artifact の target list がズレていることです。

    この誤記を放置すると、#1064 の実装で schemas/tests/ を二重に実行する、または「実行対象追加」と「artifact 追記」を混同する可能性があります。#1064 は「実行対象へ追加」ではなく、ci_test_selection/v1 生成ロジックを実行済み pytest target と一致させると書き換えるべきです。

    2. #1061 の Verification Commands は現状だと壊れています

    #1061 は python-test から setup-node-pnpm と pnpm install --frozen-lockfile を削除する issue ですが、検証コマンドが rg -c "setup-node-pnpm" .github/workflows/ci.yml と rg -c "pnpm install --frozen-lockfile" .github/workflows/ci.yml になっています。これは python-test に scope されていないため、他 job の setup-node-pnpm / pnpm install に反応します。現行 workflow では typecheck/test/build/e2e などが同じ文字列を使っており、global grep では AC を証明できません。

    検証は python-test job の YAML subtree だけを parse する必要があります。単純 grep を使うなら、少なくとも python-test: から次 job までを切り出して確認してください。より堅いのは PyYAML で .github/workflows/ci.yml["jobs"]["python-test"]["steps"] を検査する専用 one-liner です。

    3. pnpm_install phase を消すなら docs/dev/ci-performance.md も更新対象です

    #1061 は Allowed Paths を .github/workflows/ci.yml だけに限定しています。しかし docs/dev/ci-performance.md は stable phase_id として pnpm_install を python-test 対象に含めています。python-test から pnpm install を削除すると、この docs は即座に stale になります。

    これは軽微なドキュメント漏れではありません。#1059 の parent goal は ci_runtime_baseline_v1 による before/after 比較なので、phase inventory が嘘になると高速化証跡の比較軸が壊れます。#1061 の Allowed Paths に docs/dev/ci-performance.md を追加するか、別 child issue を先に切って「python-test から pnpm_install phase を除外する migration」を明示すべきです。

    4. 「4 lane 設計」と child issue の実装範囲が一致していません

    #1059 は python-test を fast-static / python-unit / contract-artifact / integration の 4 lane 設計へ移行すると書いています。ところが child issues の実体は、#1060 が docs/skill 追加、#1061 が pnpm 削除、#1063 が Ruff 追加、#1064 が pytest 統合 + xdist + artifact target 修正です。これは 4 lane を物理的に job/step 分離する計画ではなく、分類ポリシーを導入する計画に見えます。

    ここは wording を直すべきです。物理分離するなら workflow design が不足しています。概念分類なら、#1059 の Goal は「4 lane policy / classification matrix」に落とし、「4 lane 設計へ移行」という表現を避けるべきです。

    5. ci_test_selection は required evidence と optional evidence が矛盾しています

    docs/dev/ci-operations.md は python-test を required + evidence と分類し、agent merge-ready 条件として e2e / python-test の required artifact availability を要求しています。一方、現行 workflow の ci_test_selection upload は if-no-files-found: ignore です。docs 側の missing policy でも python-test の ci_test_selection は optional evidence 扱いになっています。

    #1059 は ci_test_selection の正確性を改善対象に含めるなら、missing policy も決めるべきです。最低限、#1064 の PR 本文で「今回は target list の整合だけ。artifact missing を CI failure にするかは別 issue」と明記しないと、required/evidence の意味が曖昧なまま残ります。

    6. pytest-xdist は速くなる可能性があるが、無条件 -n auto は危険です

    pytest-xdist 公式 docs は pytest -n auto により物理 CPU core 数ぶんの worker を使い、顕著な速度改善があり得ると説明しています。一方で、デフォルトの --dist load は順序保証なしで worker に配布します。module/class 単位でまとめたい場合は --dist loadscope、file 単位なら --dist loadfile が用意されています。([pytest-xdist]1)

    さらに pytest-xdist には、worker 間で test order / amount が一致しないテストは扱えないという既知制限があります。unordered set を使った parametrization などは worker ごとに collection order が変わり得ます。(pytest-xdist)

    #1064 の Stop Condition には「pytest-xdist 導入後に flake になる場合 Stop」とありますが、実装者にとっては遅すぎます。実装前に以下を AC 化してください。

    • uv run --locked pytest --collect-only -q <targets> の baseline と xdist 導入後の collect target 数が一致する
    • まず -n 0 または通常 pytest で統合 invocation が pass する
    • 次に -n auto を試す
    • flake が出た場合は --dist=loadscope / --dist=loadfile / sequential subset 分離のいずれかを PR 本文に明記する

    7. Ruff 導入は妥当。ただし「最小ルールセット」「no auto-fix」「exit code」を契約化すべきです

    Ruff は Rust 製の Python linter / formatter で、既存 linter/formatter より 10〜100 倍高速と説明されています。ruff check はファイル・ディレクトリを再帰的に受け取れます。導入初期は select = ["E", "F"] のような小さい rule set から始めることが推奨されています。([Astral Docs]3) ([Astral Docs]4)

    #1063 の方向性は正しいですが、CI gate としては次を明記してください。

    uv run --locked ruff check --select E,F .claude/scripts scripts schemas .claude/skills

    --fix は CI では禁止、--exit-zero も禁止です。Ruff は violation で exit 1、設定不備等で exit 2 になるため、fast-fail gate として使えます。([Astral Docs]4)

    8. uv dependency group の追加方法は正しいが、AC は uv lock だけでは弱いです

    現行 pyproject.toml の dev group は pytest>=8.0, pyyaml>=6.0, jsonschema>=4.0 のみで、ruff と pytest-xdist は未登録です。

    uv 公式 docs では、development dependencies は local-only で [project] ではなく [dependency-groups] に置かれ、uv add --dev pytest は dev group を作成・更新します。また dev group は既定で uv run / uv sync に含まれます。([Astral Docs]5)

    したがって #1063/#1064 は pyproject.toml 手編集 + uv lock でもよいですが、実装プロンプトでは以下を推奨します。

    uv add --dev "ruff>=0.5"
    uv add --dev "pytest-xdist>=3.6"
    uv lock
    uv sync --locked --group dev

    AC は rg -c だけでなく、実際に uv run --locked ruff --version と uv run --locked pytest --version、必要なら uv run --locked pytest -n 0 --version まで確認するべきです。

    修正すべき Issue 契約

    #1059 parent

    修正案:

    • 4 lane 設計へ移行 → 4 lane classification policy を導入し、workflow 上では Ruff fast-static step と pytest unified step に反映する
    • Parent Closure Rule に「child PR が merge 済み」「docs/dev/ci-performance.md の phase inventory が current workflow と一致」「ci_test_selection/v1 の target list が actual pytest invocation と一致」を追加
    • Wall-clock 短縮 AC は単発 before/after ではなく、少なくとも docs の方針に合わせて P50/P95 または 3-run bootstrap のどちらを使うか明記する。現行 docs は bootstrap 3 runs と decision baseline 20 runs / P50 / P95 を分けています。

    #1060

    docs/skill 追加だけなら、Skill に current implementation と target design の区別を入れてください。まだ #1061/#1063/#1064 が未実装なのに、Skill が「Ruff lane あり」「pytest unified 済み」と読める形になると、後続エージェントが未実装仕様を現行仕様として扱います。

    必須追記:

    ## Operative Status
    
    This skill describes the target CI test-lane policy for #1059.
    Until #1061/#1063/#1064 are merged, do not assume python-test has removed pnpm, added Ruff, or unified pytest invocation.

    #1061

    Allowed Paths に docs/dev/ci-performance.md を追加するか、別 child issue を作ってください。pnpm_install phase を python-test から消すのに docs を変えないのは、baseline artifact の比較可能性を壊します。

    検証コマンドは global grep ではなく、python-test job scope の YAML parse に変更してください。

    #1063

    Ruff step の contract は以下まで固定してください。

    • uv run --locked ruff check --select E,F ...
    • pytest より前
    • no --fix
    • no --exit-zero
    • target dirs は Python file のみを対象にする前提で、.claude/worktrees などの巨大・派生領域を明示除外

    #1064

    一番危険です。pytest target list を workflow 内に二重管理しているため、また同じ drift が起きます。pytest invocation と ci_test_selection/v1 の pytest_args は単一ソースから生成してください。

    最小案は .github/workflows/ci.yml 内で shell array / JSON heredoc を一度だけ定義し、それを pytest 実行と artifact generator の両方へ渡す形です。より堅い案は scripts/ci/python_test_targets.py のような小スクリプトを作ることですが、その場合 #1064 の Allowed Paths を広げる必要があります。

    実装順の推奨

    1. CI python-test pytest実行phase高速化: test lane分類・pytest統合・Ruff導入・Skill化 #1059/実装: python-test から setup-node-pnpm と pnpm install を削除する #1061/実装: pytest target plan を SSOT 化し serial→xdist 段階移行と ci_test_selection fail-close 化を行う(python-test 並列化 migration) #1064 の契約を先に修正する
    2. 実装: CI test lane policy docs と ci-test-performance skill を追加する #1060 で docs/skill を追加。ただし target design と current implementation を明確に分離する
    3. 実装: python-test から setup-node-pnpm と pnpm install を削除する #1061 で pnpm 削除 + ci-performance docs の phase inventory 更新
    4. 実装: Python fast-static lane に Ruff を fast fail-fast gate として導入する #1063 で Ruff E,F の fast-static gate を追加
    5. 実装: pytest target plan を SSOT 化し serial→xdist 段階移行と ci_test_selection fail-close 化を行う(python-test 並列化 migration) #1064 で pytest target list の SSOT 化、通常統合 invocation、次に xdist 導入
    6. 最後に ci_runtime_baseline_v1 の before/after を P50/P95 または 3-run bootstrap として PR body に貼る

    そのまま投げるなら、このプロンプト

    Issue #1059 と child #1060/#1061/#1063/#1064 を実装前に再監査してください。
    
    特に以下を BLOCKER として扱ってください。
    
    1. #1061 の Verification Commands は global rg であり、python-test job に scope されていないため不正です。YAML parse または python-test section 限定検証に修正してください。
    2. python-test から pnpm_install phase を削除するなら docs/dev/ci-performance.md の stable phase_id inventory も更新対象にしてください。Allowed Paths を広げるか、別 child issue を作成してください。
    3. schemas/tests/ は現行 python-test で既に実行されています。問題は実行漏れではなく ci_test_selection/v1 の pytest_args から欠落している artifact drift です。#1059/#1064 の文言を修正してください。
    4. #1059 の「4 lane 設計」は物理 job/lane 分離なのか classification policy なのか曖昧です。現 child scope に合わせて classification policy と明記してください。
    5. pytest-xdist は無条件 -n auto にせず、通常統合 invocation pass、collect-only target 数一致、xdist pass、必要時 --dist=loadscope/loadfile または sequential subset 分離を AC に入れてください。
    6. Ruff は `uv run --locked ruff check --select E,F ...`、pytest より前、no --fix、no --exit-zero を契約化してください。
    7. ci_test_selection/v1 は actual pytest target list と同一ソースから生成するようにしてください。二重管理を残さないでください。
    
    上記を反映して Issue 本文または child issue を修正し、その後 1 Issue = 1 PR で実装してください。破壊的操作、権限不足、外部課金、秘密情報露出の可能性がある場合のみ停止してください。
    

    現状判定は 実装着手前に Issue 契約修正が必要です。方向性は良いですが、今のまま進めると CI 高速化より先に証跡契約が壊れます。

  3. squne121 commented on Jun 20, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES。Issue #1059 は現時点ではクローズ不可です。

    主要 child の実装自体は進んでいます。しかし親Issueの完了条件と Verification Commands が一致しておらず、現在の main も「Python-only lane」「pytest統合済み」「正本ドキュメントと実装が同期」という親ゴールから再び乖離しています。

    特に重大なのは、親AC2が「Python test の wall-clock短縮」を要求しているのに、実際の証跡が pytest部分だけの時間を測定している点です。また、AC1の「child issueがマージ済み」という条件を、単なるIssueの closed 状態で検証しているため、手動クローズや not_planned でも通過できます。

    実装上、評価できる部分

    #1064で追加された以下の設計は妥当です。

    • pytest対象、--ignore、--deselect、worker数、schedulerを .github/ci/python-test-plan.json に集約した
    • shell eval を使わず、NUL区切りargvを介して安全にworkflowへ渡した
    • worker数を固定4、schedulerを loadscope に固定した
    • parallel laneとserial laneの和集合・排他性を検証している
    • pytest collection失敗、timeout、nodeid 0件、git diff失敗をfail-closeにした
    • uv run --locked によりlockfile driftを拒否している

    これらは、pytest-xdistが全workerで同一のcollection順序・件数を要求することや、-n auto が実行環境のCPU数に依存することを考えると、再現可能性の面で正しい方向です。 ([pytest-xdist]1)

    ただし、これらの強い基盤の上に、後続変更による契約driftが積み重なっています。


    Blocker

    P0-1. 親Issueのclose判定がfalse positiveを許す

    親IssueのClosure Ruleは「#1060/#1061/#1063/#1064がすべてマージ済み」を要求しています。しかしVerification Commandsは各Issueの state や closedAt しか確認していません。これは「実装PRがmainへマージされた」「期待した成果物がmainに存在する」を証明しません。

    実際、この系譜にある #1097 は、Claude Code向けroutingを追加するIssueとして作成されたものの、最終的には state_reason: not_planned でクローズされています。Issueのclosed状態だけを完了証拠に使えない実例です。

    改善案

    親のclose verifierは、少なくとも次を検証すべきです。

    child_delivery:
      - issue: 1060
        merged_pr: 1078
        merge_commit_sha: "<40-hex>"
        required_paths:
          - docs/dev/test-lane-policy.md
          - .claude/skills/ci-test-performance/SKILL.md
      - issue: 1061
        merged_pr: 1121
      - issue: 1063
        merged_pr: 1129
      - issue: 1064
        merged_pr: 1151

    検証は以下を組み合わせます。

    1. PRが merged == true
    2. merge commitが現在のmainのancestor
    3. childごとのrequired pathsがmainに存在
    4. childの最終ACを現行mainに対して再検証
    5. Issueのclose reasonが completed

    親のcloseは「過去にchildが閉じたか」ではなく、現行mainが親ゴールの不変条件を満たすかで判定する必要があります。


    P0-2. AC2は「Python test wall-clock短縮」を証明していない

    親AC2は、ci_runtime_baseline_v1 により「Python test のwall-clockが短縮していること」を要求しています。ところが #1064 の比較式は、以下だけを合計しています。

    python_pytest_total_ms = pytest_parallel_ms + pytest_serial_ms
    

    Codex CLI導入、Codex execpolicy、Ruff、uv環境構築、artifact生成、その他のPython関連処理は含まれていません。証跡上はpytest部分がP50で約221秒から約78秒へ短縮されていますが、これは pytest phaseの高速化であり、python-test job全体のwall-clock短縮ではありません。

    現在の python-test には、pytest parallel/serial laneの後にNode.jsセットアップ、Codex CLIのnpm導入、Codex実行、別のpytest invocationが存在します。したがって、pytest部分が高速化していても、job全体が遅くなっている可能性を現在のAC2は検出できません。

    改善案

    次のどちらかへ契約を明確化します。

    案A:親ACを狭める

    AC2: python-test job内のpytest実行phase
         (pytest_parallel + pytest_serial)のP50/P95が短縮していること
    

    この場合、IssueタイトルとOutcomeも「Python test高速化」ではなく「pytest execution phase高速化」に修正します。

    案B:本来の親ゴールを維持する

    python_test_job_total_ms =
      first_execution_step_started_at
      → final_required_evidence_step_completed_at
    

    同一の以下のcohort fingerprintでbase/head各20 runを比較します。

    runner_image:
    runner_arch:
    python_version:
    uv_version:
    pytest_version:
    xdist_version:
    workers:
    scheduler:
    python_test_plan_digest:
    lockfile_digest:
    workflow_digest:

    最終判断には、pytest phaseとjob totalの両方を残すべきです。


    P0-3. 「Python-only lane」「pytest統合済み」という不変条件が現在は成立していない

    #1123は、#1061でNode/pnpmを削除した結果、Node-backed hook testsがfresh runnerで失敗したため、「python-test をPython-only laneとして成立させる」目的で追加されています。

    しかし現在の python-test には以下が再混入しています。

    • actions/setup-node@v6
    • npm経由のCodex CLI導入
    • Codex execpolicy runtime
    • plan外の別pytest invocation

    これはpnpmの再導入ではありませんが、Python-only laneという設計境界は失われています。また「pytestをplan駆動の単一stepへ統合」という説明とも一致しません。

    改善案

    Codex関連を独立jobへ移します。

    jobs:
      python-test:
        # Python + uv + Ruff + plan-driven pytest only
    
      codex-execpolicy:
        # Node/npm + pinned Codex CLI + Codex-specific pytest
    
      node-backed-hook-tests:
        # pnpm/Node-backed hook runtime

    さらにworkflowをYAMLとして構造解析し、以下をfail-closeで固定します。

    python_test_invariants:
      forbidden_actions:
        - actions/setup-node
        - setup-node-pnpm
      forbidden_commands:
        - npm
        - pnpm
        - node
        - codex
      pytest_policy:
        plan_driven_invocations: 2  # parallel + serial
        undeclared_invocations: 0

    単純な rg -c pytest ではなく、YAML AST上の jobs.python-test.steps を検査すべきです。


    P0-4. 正本ドキュメントとSkillが現行実装を誤って説明している

    現行planは固定 workers: 4、dist: loadscope です。ところがcanonical Skillは「pytest-xdist導入後の推奨」として -n auto --dist loadscope を示し、別箇所でも「pytest -n autoを導入済み」と記述しています。 -n auto は物理CPU数に依存するため、固定cohortでの性能比較方針とも矛盾します。 (pytest-xdist)

    docs/dev/test-lane-policy.md とSkillは、次のような古い状態も残しています。

    一方、#1080は既にcompletedで、現行 node-backed-hook-tests も当初の2 nodeid以外へ拡張されています。

    Claude Code agent向けの明示routingを扱った #1097 は not_planned で閉じられており、現行検索では CI_SKILL_ROUTING はCodex agent定義にしか確認できません。

    CodexのSkillは、最初に名前とdescriptionだけが読み込まれ、descriptionとの一致により暗黙選択されます。公式文書も、hooksは有用なguardrailではあるものの完全なenforcement boundaryではないと説明しています。したがって、staleなSkill本文・description・routingは単なる文書不備ではなく、エージェントが誤ったCI変更を行う運用障害です。 ([OpenAI Developers]2)

    改善案

    手作業で同期する方式を廃止し、次を追加します。

    scripts/ci/verify_ci_test_performance_contract.py
    

    検証対象:

    • planのworkers/scheduler
    • workflow内のjob構成
    • pytest invocation数
    • Ruff command/config
    • node-backed dedicated paths
    • stable phase inventory
    • hook advisoryの実装状態
    • Skill内のcurrent-state block
    • .claude/agents と .codex/agents のrouting方針

    「Target Policy」と「Current Implementation」は別の機械可読ブロックに分離すべきです。


    High priority

    P1-1. 手動test target allowlistでは全テスト収集を保証できない

    現行planのnoteには、tests/test_hook_boundaries_doc.py が既に存在していたにもかかわらず、ファイルが変更されるまでplanへ登録されておらず、登録後に既存の失敗2件が露見したと記録されています。その2件は現在 deselect されています。

    #1644でも、PRで追加されたtest fileをpython-test-planへ後追い登録する作業が必要になっています。同Issue自身もdirectory-wideの未分類Python test guardをスコープ外として残しています。

    これは次の攻撃・故障経路を残します。

    1. 新しいtest fileを追加する
    2. planへ登録しない
    3. そのtestはCIで実行されない
    4. ファイルがそのPRのchanged-test判定に入らない条件では、長期間見つからない
    5. 後日登録した時点で既存failureが発覚し、deselect で隔離される

    pytest-xdistは各workerが全collectionを実行し、同一collectionを要求しますが、そもそもpytestへ渡していないファイルの存在は検出しません。 (pytest-xdist)

    改善案

    リポジトリ内の全Python testを分類するinventory gateを追加します。

    test_inventory:
      discovered:
        patterns:
          - "**/test_*.py"
          - "**/*_test.py"
    
      classifications:
        - python_test_plan
        - node_backed_lane
        - codex_execpolicy_lane
        - runtime_verification_only
        - quarantine

    すべてのtest fileが正確に1分類されることを検証します。

    可能な箇所はファイル単位列挙ではなく、ディレクトリ単位targetへ移行します。個別ファイルtargetが必要な場合は、理由をmachine-readableに要求します。


    P1-2. ignore / deselect が恒久quarantineとして無期限化している

    現行planには以下があります。

    • #412に紐づくignored test
    • Node-backed wrapperの2 nodeid
    • hook-boundariesの既存failure 2 nodeid
    • 並列不安全testのserial分離

    特にhook-boundariesの2件は、noteに「follow-upで修正すべき」と書かれているだけで、Issue番号、owner、期限、解除条件がplan上にありません。

    改善案

    rawな deselect: [string] を廃止し、次の形にします。

    quarantines:
      - nodeid: tests/test_hook_boundaries_doc.py::...
        issue: 1750
        owner: agent-ops
        reason_code: preexisting_contract_drift
        introduced_at: 2026-07-25
        expires_at: 2026-08-31
        required_lane: none

    validatorは以下を拒否します。

    • Issue番号なし
    • expiryなし
    • 期限切れ
    • 重複
    • 存在しないnodeid
    • target scope外
    • reason_code未定義

    serial laneも単なる隔離ではなく、非hermeticな実装を直すための期限付きquarantineとして管理すべきです。


    P1-3. python_test_plan のfail-closed保証が後付けフィールドへ及んでいない

    中央loaderの load_plan() が厳格に検証しているのは、主に以下です。

    • schema_version
    • targets
    • ignore
    • deselect
    • parallel_exclude
    • xdist

    一方、後から追加された以下は同じ場所で検証されません。

    • secondary_coverage
    • runtime_verification_only_markers
    • notes
    • 未知のtop-level key

    generate_ci_test_selection_artifact.py は secondary_coverage やruntime markerの読込エラーを文字列としてartifactに記録しますが、最終exit codeを決めるのはcollection、git diff、uncovered changed testsです。設定エラー自体は常にfatalではありません。テストも、secondary coverage metadataのエラーを「記録されること」として検証しており、無変更時にCI全体を落とす契約にはなっていません。

    つまり「planはfail-closed」という説明は、現在の全フィールドについては成立しません。

    改善案

    python_test_plan/v2 をJSON Schema化します。

    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema_version",
        "targets",
        "ignore",
        "quarantines",
        "xdist",
        "secondary_coverage"
      ]
    }

    さらに以下を検証します。

    • provider_job がworkflow内に実在する
    • dedicated laneのpathが存在する
    • 同じpathが複数providerに登録されない
    • provider jobが実際にそのpathをcollectしたartifactを発行する
    • provider artifactのhead SHAが対象PR headと一致する
    • runtime-only markerがpyproject.tomlに登録されている
    • plan errorがchanged fileの有無にかかわらず即fatal

    #1724でも、cross-job coverageについてprovider側の実artifact・collected nodeid・head SHAを照合する仕組みが残余gapとして明示されています。


    P1-4. Ruff設定がSSOT化されておらず、実装・Skill・docsがdriftしている

    pyproject.toml のRuff設定は主にline lengthのみで、実際のrule setである --select E,F --ignore E402 と対象pathはworkflowのCLIへ埋め込まれています。Skill内には ruff check . や異なる例も残っています。

    Ruffは pyproject.toml の lint.select、lint.ignore、lint.per-file-ignores を正本として利用できます。CLIオプションは設定をoverrideするため、現在の方式は文書・ローカル実行・CI間のdriftを作りやすい設計です。 ([Astral Docs]4)

    改善案

    [tool.ruff]
    line-length = 120
    
    [tool.ruff.lint]
    select = ["E", "F"]
    
    [tool.ruff.lint.per-file-ignores]
    "scripts/specific_bootstrap.py" = ["E402"]
    ".claude/hooks/specific_loader.py" = ["E402"]

    workflowは次の単純な呼出しにします。

    uv run --locked ruff check .claude/scripts scripts schemas .claude/skills

    E402を全領域でglobal ignoreするのではなく、本当にimport-order例外が必要なファイルへ限定すべきです。


    P1-5. 親ACに必要なruntime artifactがfail-openでuploadされる

    ci_runtime_baseline_v1 のuploadは if-no-files-found: warn です。つまりartifact生成に失敗しても、upload step自体は警告で継続できます。親AC2の必須証拠として扱うなら不適切です。

    GitHub公式の upload-artifact は、if-no-files-found: error を指定すると該当ファイルがない場合にactionを失敗させられます。 (GitHub)

    改善案

    通常PRでoptional artifactとする場合と、性能判定runを分離します。

    - name: Validate CI runtime artifact
      if: inputs.python_test_bench == 'true'
      run: |
        test -s ci_runtime_baseline_artifacts/ci_runtime_baseline_v1.json
        uv run --locked python scripts/ci/validate_ci_runtime_baseline.py ...
    
    - uses: actions/upload-artifact@<full-sha>
      if: inputs.python_test_bench == 'true'
      with:
        if-no-files-found: error

    artifactの存在だけでなく、最低サンプル数、run ID重複、runner cohort、phaseの完全性も検証対象にします。


    Medium priority hardening

    P2-1. scheduler選定証拠のcohortが弱い

    loadscope、load、worksteal の比較はWSL2上の各3 runで行われ、その後のbase/head 20 runは採用schedulerだけをGitHub-hosted runner上で測っています。fixture再利用の説明は合理的ですが、「CI runnerでも最適」という判断を直接実測したわけではありません。

    schedulerを選択する性能主張を行うなら、固定worker数・同一GitHub runner image上で候補を比較すべきです。ローカル比較を使う場合は「選択用heuristic」であり、CI性能証拠ではないと明記します。

    P2-2. benchmark-sensitive workflowのAction参照をfull SHAへ固定する

    現行workflowは actions/checkout@v6、actions/setup-node@v6、actions/upload-artifact@v7 のmajor tag参照です。major tagは運用上便利ですが、長期的なbenchmark再現性やsupply-chain境界ではfull commit SHA固定の方が強固です。

    GitHubはActions policyでfull-length commit SHAへの固定を要求でき、セキュリティ上もimmutableなSHA pinningを推奨しています。 ([GitHub Docs]6)

    少なくとも性能baseline収集workflowでは、Action SHA、Codex package version、lockfile digestをcohort fingerprintへ含めるべきです。

    P2-3. 高リスクなCI migrationに独立レビュー証拠が弱い

    PR #1151の記録されたレビューでは、self-authored PRであり、review subagentが利用できなかったためcontrol-planeが手順を代行したと明記されています。また、20-run数値の妥当性は人間監査へ委ねられています。

    これは実装不良の直接証拠ではありませんが、CI coverage、性能数値、fail-close契約を同時に変更するPRとしては独立性が弱い状態です。将来は次のいずれかを要求すべきです。

    • 別モデルまたは別sessionによる独立レビュー
    • base/head run artifactを再計算するmachine verifier
    • PR作者以外のreview approval
    • committed summaryとGitHub artifactのdigest照合

    親Issueの改訂Closure Contract案

    #1059は、元の4 childを閉じるだけのdelivery-rollupではなく、current-state invariant parent に更新すべきです。

    parent_closure_contract_v2:
      delivery:
        original_children:
          - issue: 1060
            merged_pr: 1078
          - issue: 1061
            merged_pr: 1121
          - issue: 1063
            merged_pr: 1129
          - issue: 1064
            merged_pr: 1151
    
      current_state_invariants:
        python_test_lane:
          node_runtime_present: false
          package_manager_present: false
          codex_runtime_present: false
          undeclared_pytest_invocations: 0
    
        test_inventory:
          all_python_test_files_classified: true
          unowned_quarantines: 0
          expired_quarantines: 0
    
        plan:
          schema_valid: true
          unknown_properties: 0
          secondary_coverage_verified: true
          runtime_marker_contract_valid: true
    
        documentation:
          workflow_skill_policy_parity: true
          stale_current_state_statements: 0
    
      performance:
        metric_scope: python_test_job_total_ms
        base_runs: 20
        head_runs: 20
        same_runner_image: true
        same_plan_digest: true
        same_workers: true
        same_scheduler: true
        p50_improved: true
        p95_not_regressed: true
        artifact_required: true
    
      canonical_gates:
        - pnpm typecheck
        - pnpm lint
        - pnpm test
        - pnpm build
        - python-test
        - node-backed-hook-tests
        - codex-execpolicy
        - actionlint

    最終結論

    #1059の中核実装、特にpytest plan SSOT、固定worker、lane union、collection/diffのfail-closeは高品質です。しかし親Issueとしては、次の3点が未解決です。

    1. 完了証明がIssue closed状態とpytest部分時間に置き換わっている
    2. 後続変更によりPython-only / unified laneの設計境界が崩れている
    3. Skill・policy・workflow・test inventoryのcurrent-state同期を機械保証できていない

    したがって、現時点の判定は REQUEST_CHANGES / keep open です。親本文を上記Closure Contractへ更新し、少なくともP0の4項目を解消してからclose判定を再実施すべきです。

  5. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "issue-reviewer SubAgentの最終応答がISSUE_REVIEW_RESULT_COMPACT_V1正規stdout形式でなくprose要約だったため、validate_review_compact_output.pyがvalidation_status: invalidを返した(missing_field: STATUS/VERDICT/SUMMARY/BLOCKERS/NEXT_ACTION/MUST_READ/EVIDENCE/ARTIFACT)"
    
    "SKILLのvalidator-first原則によりVERDICT自己申告は使用不可。fail-closedでhuman_judgment_requiredに固定"
    
    "参考: 決定論的checkerが直接生成したcompact_review_result_20260725T133430Z.json artifactはVERDICT: approve・blockers_count:1(pnpm testのbaseline regression、AC3該当)だが、diff_proposalは空でOWNER anchor comment(P0-1/P0-2/P0-3/P0-4、parent_closure_contract_v2提案)を本文へ反映する提案を含んでいない"
    
    "anchor_comment_feedback.classification_reasonがdefaulted_by_preflight_schema_normalization; semantic classification deferred to #1008/#1011であり、anchor commentの意味的スコープ判定自体が本loopのplanner未対応領域"
    
    "web-research fact-checkは完了済み(pytest-xdist collection同期・-n auto CPU依存・upload-artifact if-no-files-found: error は検証済み。GitHub Actions SHA pinning「必須」主張は不正確で「推奨/任意強制可能」が正確)"
    
  6. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    判定

    現行の #1059 契約を基準にすると、Closeのために新しい実装Issueを追加する必要はありません。

    #1059 は、OWNERレビューのうちP0-1「child完了証明」とP0-2「性能指標のスコープ」を本文へ反映済みです。一方、Python-only境界、ドキュメント同期、test inventory、quarantine、Ruff SSOT、artifact fail-closeなどは、明示的に非ブロッキングのfollow-up候補へ降ろされています。

    元のchild PRはすべてmerge済みです。

    AC2のpytest実行phaseについても、同一runner imageでbase/head各20 runを比較し、P50は221130.5 ms → 77882.0 ms、P95は228195.5 ms → 80564.4 msへ短縮した証跡があります。

    最新取得できたPR headのCIでは、typecheck、test、build、python-testを含むci workflowが成功しています。ただし、#1059の契約は「現行main」での確認を要求しているため、最終main SHAに対する証跡固定だけはClose前に再実行すべきです。

    Close前に必要な作業

    これは新規Issueではなく、#1059自身への最終コメントとして実施するのが適切です。

    PARENT_CLOSURE_VERIFICATION_V1:
      parent_issue: 1059
      verified_at: "<UTC timestamp>"
      current_main_sha: "<40-hex SHA>"
    
      ac1_child_delivery:
        - issue: 1060
          close_reason: completed
          closing_pr: 1078
          merged: true
          merge_commit_sha: 7b8167774a16d5506dbb88670f3b68b75b22053a
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - docs/dev/test-lane-policy.md
            - .claude/skills/ci-test-performance/SKILL.md
    
        - issue: 1061
          close_reason: completed
          closing_pr: 1121
          merged: true
          merge_commit_sha: db86c058f2c18d4c9abeb06f074ed814fcfc44ec
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - .github/workflows/ci.yml
            - docs/dev/ci-performance.md
    
        - issue: 1063
          close_reason: completed
          closing_pr: 1129
          merged: true
          merge_commit_sha: f2ee8f662add514fe531fcc1a2bad81405c62f97
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - pyproject.toml
    
        - issue: 1064
          close_reason: completed
          closing_pr: 1151
          merged: true
          merge_commit_sha: 54858e277144d670eb2b24a1f96d82515f295c87
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - .github/ci/python-test-plan.json
            - .github/workflows/ci.yml
    
      ac2_performance:
        metric_scope: python_pytest_total_ms
        formula: pytest_parallel_ms + pytest_serial_ms
        runner_image: ubuntu24/20260615.205.1
        base_runs: 20
        head_runs: 20
        base_p50_ms: 221130.5
        head_p50_ms: 77882.0
        base_p95_ms: 228195.5
        head_p95_ms: 80564.4
        p50_improved: true
        p95_improved: true
        evidence: docs/dev/ci-runtime-baseline-1064.md
    
      ac3_current_main:
        pnpm_typecheck: pass
        pnpm_test: pass
        pnpm_build: pass
        ci_run_id: "<current-main run ID>"
    
      decision: close_ready

    併せてAC1~AC3のチェックボックスを更新し、close reasonをcompletedにします。タイトルも実際の限定された性能主張に合わせ、次へ直すのが妥当です。

    CI python-test pytest実行phase高速化: test lane分類・pytest統合・Ruff導入・Skill化


    Close後の後継Issue案

    以下は**#1059のchildにはしない**でください。parent_issue: none、related_issues: "#1059"とし、#1059のCloseを阻害しない独立follow-upにします。

    Issue案1: Codex runtimeを専用jobへ分離する

    現行python-testには、plan駆動pytestの後にactions/setup-node@v6、Codex execpolicy、Codex固有pytestが存在します。そのため、過去に成立させたPython-only境界と「plan駆動pytestのみ」という説明が現在は成立しません。

    タイトル

    ci: Codex execpolicyを専用jobへ分離しpython-testのPython-only invariantを復元する

    本文案

    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    related_issues: "#1059, #1061, #1064, #1123"
    goal_ref: "python-testからNode/npm/Codex runtimeとCodex固有pytestを分離し、Python/uv/Ruff/plan-driven pytest専用laneとして機械保証する"
    change_kind: workflow

    Current Validated Scope

    • python-test jobにはactions/setup-node@v6が存在する。
    • 同job内でCodex CLIの導入とexecpolicy matrixを実行している。
    • Codex固有pytestは.github/ci/python-test-plan.jsonのplan外で実行される。
    • そのため、Python-only laneおよびplan-driven pytest invariantが成立していない。

    Outcome

    • python-testはPython、uv、Ruff、plan-driven parallel/serial pytestのみを実行する。
    • Codex CLI、Node/npm、execpolicy matrix、Codex固有pytestはcodex-execpolicy専用jobへ移す。
    • YAML ASTを検査するinvariant verifierにより、Node/Codexの再混入とplan外pytestをfail-closeで拒否する。

    In Scope

    • .github/workflows/ci.ymlへのcodex-execpolicy job追加
    • Codex関連stepとartifact uploadの移動
    • scripts/ci/verify_python_test_lane.pyの追加
    • job間のrequired gate・artifact責務の更新
    • docs/dev/ci-performance.md
    • docs/dev/test-lane-policy.md
    • .claude/skills/ci-test-performance/SKILL.md

    Out of Scope

    • pytest target inventory全体の再設計
    • python_test_plan schema migration
    • job totalの性能比較
    • Codex execpolicyテスト自体の意味変更

    Acceptance Criteria

    • AC1: jobs.python-test.stepsにactions/setup-node、setup-node-pnpmが存在しない
    • AC2: python-test内にnode、npm、pnpm、codexを起動するcommandが存在しない
    • AC3: python-test内のpytest実行はplan由来のparallel laneとserial laneのみである
    • AC4: codex-execpolicy jobが既存execpolicy matrixとCodex固有pytestを実行する
    • AC5: Codex関連artifactが専用jobからfail-closeでuploadされる
    • AC6: invariant verifierがNode/Codex再混入、plan外pytest、job欠落を拒否するnegative testを持つ
    • AC7: docs、Skill、stable phase inventoryが変更後workflowと一致する
    • AC8: actionlint、python-test、codex-execpolicy、node-backed-hook-testsが成功する
    • AC9: pnpm typecheck、pnpm lint、pnpm test、pnpm buildが成功する

    Allowed Paths

    • .github/workflows/ci.yml
    • scripts/ci/verify_python_test_lane.py
    • scripts/ci/tests/
    • docs/dev/ci-performance.md
    • docs/dev/test-lane-policy.md
    • .claude/skills/ci-test-performance/SKILL.md

    Runtime Verification Applicability

    decision: immediate
    reason: "GitHub Actionsのjob境界とrequired test executionを変更するため、当該PRの実CI runで検証する"
    
    ---
    
    ## Issue案2: python-test-planをstrict schema化する
    
    現行loaderが厳格に扱うのは主に`targets`、`ignore`、`deselect`、`parallel_exclude`、`xdist`です。`secondary_coverage`など後付けフィールドは同じ強度で検証されず、rawな`deselect`にはIssue、owner、期限がありません。
    
    ### タイトル
    
    **ci: python_test_plan/v2をstrict schema化し期限付きquarantine契約を導入する**
    
    ### 本文案
    
    ```markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    related_issues: "#1059, #1064"
    goal_ref: "python-test planの全フィールドをfail-closedで検証し、テスト除外をowner・Issue・期限付きquarantineとして統治する"
    change_kind: schema-and-tooling
    

    Outcome

    python_test_plan/v2をJSON Schemaで定義し、未知キー・型不一致・不正path・不正markerを拒否する。
    rawな恒久deselectを、Issue、owner、reason、導入日、期限、解除条件を持つ構造化quarantineへ移行する。

    In Scope

    • .github/ci/python-test-plan.schema.jsonの追加
    • .github/ci/python-test-plan.jsonのv2移行
    • scripts/ci/python_test_plan.pyの全フィールド検証対応
    • quarantine expiry/nodeid/path検証
    • generator consumerのv2対応
    • positive/negative fixtureと回帰テスト
    • policy docs更新

    Quarantine Contract

    quarantines:
      - nodeid: tests/example.py::test_example
        issue: 1234
        owner: agent-ops
        reason_code: preexisting_contract_drift
        introduced_at: 2026-07-25
        expires_at: 2026-08-31
        required_lane: none
        removal_condition: "Issue #1234の修正PRがmainへmergeされること"

    Acceptance Criteria

    • AC1: schemaがadditionalProperties: falseである
    • AC2: planの全top-level fieldがrequiredまたは明示的optionalとして定義される
    • AC3: secondary_coverageとruntime_verification_only_markersの構造エラーが常にfatalになる
    • AC4: quarantineはIssue、owner、reason_code、introduced_at、expires_at、removal_conditionを必須とする
    • AC5: 期限切れ、重複、存在しないnodeid、target scope外nodeidを拒否する
    • AC6: unknown propertyをchanged testの有無に関係なく拒否する
    • AC7: technical collection boundary用のignoreと、失敗test隔離用quarantineが区別される
    • AC8:既存planが意味を変えずv2へ移行される
    • AC9: loader、workflow、artifact generatorが同じvalidated plan objectを消費する
    • AC10: negative fixtureが各fail-close経路を検証する

    Out of Scope

    • quarantine対象テスト本体の修正
    • provider job artifactとの実行証跡照合
    • 全test file inventoryの一意分類

    Allowed Paths

    • .github/ci/python-test-plan.json
    • .github/ci/python-test-plan.schema.json
    • scripts/ci/python_test_plan.py
    • scripts/ci/tests/
    • .claude/skills/pr-review-judge/scripts/generate_ci_test_selection_artifact.py
    • .claude/skills/pr-review-judge/scripts/tests/
    • docs/dev/test-lane-policy.md
    • .claude/skills/ci-test-performance/SKILL.md
    
    ---
    
    ## Issue案3: 全test inventoryとcross-job証跡をfail-close化する
    
    #1725は、宣言だけ存在して実行されていなかった`test_external_manifest_publish.py`を実際のNode-backed laneへ追加するIssueです。しかし、provider jobのartifact、collected nodeid、head SHAを照合する一般的な仕組みは明示的にスコープ外です。
    
    ### タイトル
    
    **ci: 全Python test inventoryを一意分類しcross-job coverageをhead SHA付きartifactで証明する**
    
    ### 本文案
    
    ```markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    related_issues: "#1059, #1064, #1644, #1724, #1725"
    depends_on: "#1725"
    goal_ref: "リポジトリ内の全Python test fileを正確に1つのlaneへ分類し、secondary coverageをprovider jobの実行artifactで証明する"
    change_kind: ci-test-coverage
    

    Current Validated Scope

    • 新規test fileはpython-test-planへ明示登録されない限りCI対象外になり得る。
    • secondary_coverage.dedicated_lanesはprovider jobの実行artifactを検証せず、宣言を信頼している。
    • #1725は具体的な1ファイルの実行漏れを修正するが、一般的なcross-job検証は扱わない。

    Outcome

    • repository内の全Python test fileが正確に1分類される。
    • dedicated provider jobは、head SHA付きselection artifactを発行する。
    • 集約gateは、plan宣言とprovider jobの実collected files/nodeidsを照合する。
    • 未分類、重複分類、artifact欠落、stale SHA、宣言のみcoverageをfail-closeで拒否する。

    Classifications

    classifications:
      - python_test_plan
      - node_backed_lane
      - codex_execpolicy_lane
      - runtime_verification_only
      - quarantine

    In Scope

    • scripts/ci/verify_python_test_inventory.py
    • provider artifact schema
    • node-backed/Codex/python-test各jobのselection artifact生成
    • aggregation専用ci-test-coverage-gate job
    • generatorのsecondary_coverage consumer更新
    • inventory除外規則の明文化
    • fixture/negative test

    Acceptance Criteria

    • AC1: **/test_*.pyおよび**/*_test.pyを規定された除外領域以外から列挙する
    • AC2: 全test fileが正確に1分類される
    • AC3: 未分類・複数分類をchanged fileの有無に関係なく拒否する
    • AC4: provider artifactがhead_sha、run_id、run_attempt、provider_job、collected files/nodeidsを持つ
    • AC5: provider artifactのhead_shaが対象PR headと一致しない場合に拒否する
    • AC6: secondary_coverage宣言pathがprovider artifactで実際にcollectされていることを検証する
    • AC7: provider artifact欠落、0 nodeid、重複providerを拒否する
    • AC8: #1725の対象を含むNode-backed fileが実行・collectの双方で証明される
    • AC9: inventory、provider、aggregationのnegative testを持つ
    • AC10: required CIでci-test-coverage-gateが成功する

    Out of Scope

    • 各testの意味変更
    • quarantine自体の修正
    • CI performance benchmark

    Allowed Paths

    • .github/workflows/ci.yml
    • .github/ci/python-test-plan.json
    • scripts/ci/verify_python_test_inventory.py
    • scripts/ci/tests/
    • .claude/skills/pr-review-judge/scripts/generate_ci_test_selection_artifact.py
    • .claude/skills/pr-review-judge/scripts/tests/
    • docs/dev/test-lane-policy.md
    • .claude/skills/ci-test-performance/SKILL.md
    
    ---
    
    ## Issue案4: Ruffとdocs/SkillのSSOT driftを防止する
    
    現行`pyproject.toml`のRuff設定は主にline lengthだけで、`E/F`選択や`E402`除外はworkflowのCLIに埋め込まれています。 現行docs/Skillにも、固定2 nodeid、単一pytest step、将来の#1080対応、`-n auto`など現在と合わない記述が残っています。   
    
    ### タイトル
    
    **ci: Ruff設定をpyproject.tomlへ集約しCI test-lane contract parity verifierを追加する**
    
    ### 本文案
    
    ```markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    related_issues: "#1059, #1060, #1063, #1064, #1080, #1725"
    goal_ref: "Ruff設定とCI test-lane current stateをSSOT化し、workflow・plan・docs・Skill間のdriftをCIで拒否する"
    change_kind: tooling-and-docs
    

    Outcome

    • Ruffのrule選択と例外をpyproject.tomlへ集約する。
    • workflowは正本設定を利用する単純なruff check commandにする。
    • verify_ci_test_performance_contract.pyがworkflow、plan、docs、Skillのcurrent-state invariantを検証する。

    In Scope

    • [tool.ruff.lint]へのselect = ["E", "F"]
    • global E402 ignoreの廃止または最小化
    • 必要ファイルだけへのper-file-ignores
    • workflow Ruff commandの簡素化
    • scripts/ci/verify_ci_test_performance_contract.py
    • docs/SkillのCurrent Implementation block更新
    • parity negative fixtures

    Verifier Scope

    • planのworkers/scheduler
    • python-testとdedicated jobの構成
    • plan-driven pytest invocation数
    • Ruff configとworkflow command
    • node-backed/Codex dedicated targets
    • stable phase inventory
    • hook advisoryの実装状態
    • docs/SkillのCurrent Implementation block
    • Claude/Codex agent routing記述

    Acceptance Criteria

    • AC1: Ruff rule selectionがpyproject.tomlに定義される
    • AC2: workflowに--select E,Fやglobal --ignore E402を重複定義しない
    • AC3: E402例外が必要な場合は具体的ファイル単位で定義される
    • AC4: verifierがplan workers/distとworkflow/docs/Skillの不一致を拒否する
    • AC5: verifierがjob構成、pytest invocation、dedicated targetの不一致を拒否する
    • AC6: verifierがstable phase inventoryの欠落・余剰を拒否する
    • AC7: #1080を未実装扱いする古い記述が残っていない
    • AC8: target policyとcurrent implementationが明確に分離される
    • AC9:各種driftを再現するnegative fixturesが存在する
    • AC10: Ruff、verifier、actionlint、標準CI gateが成功する

    Allowed Paths

    • pyproject.toml
    • .github/workflows/ci.yml
    • scripts/ci/verify_ci_test_performance_contract.py
    • scripts/ci/tests/
    • docs/dev/ci-performance.md
    • docs/dev/test-lane-policy.md
    • .claude/skills/ci-test-performance/SKILL.md
    • .agents/skills/ci-test-performance/SKILL.md
    
    ---
    
    ## Issue案5: job全体計測とartifact fail-close化
    
    現行#1059は、性能指標をpytest phaseに限定しています。job全体の計測は明示的に未起票follow-upです。 また、通常の`ci_runtime_baseline_v1` uploadは`if-no-files-found: warn`であり、必須性能証拠としてはfail-openです。
    
    #1724はV2 assessment schemaとvalidatorを実装しましたが、workflow配線、cross-job coverage、一般化されたcohort契約はfollow-upとして残しています。新しいIssueではV2 schemaを再定義せず、既存validatorを利用します。
    
    ### タイトル
    
    **ci: python-test job total benchmark workflowを追加しci_runtime_baselineをfail-closed化する**
    
    ### 本文案
    
    ```markdown
    ## Machine-Readable Contract
    
    ```yaml
    contract_schema_version: v1
    issue_kind: implementation
    parent_issue: none
    related_issues: "#1059, #1064, #1538, #1724"
    depends_on: "Codex execpolicy dedicated-job separation issue"
    goal_ref: "python-test job全体のwall-clockを比較可能なcohortで測定し、benchmark modeではruntime artifact欠落・不整合をfail-closeにする"
    change_kind: workflow-and-instrumentation
    

    Current Validated Scope

    • #1059の性能証拠はpytest_parallel_ms + pytest_serial_msに限定される。
    • Node/Codex setup、execpolicy、policy check、artifact generationを含むjob totalは未計測。
    • 通常CIのruntime baseline artifactはファイル未生成時にwarningで継続する。
    • CI_TEST_PERFORMANCE_ASSESSMENT_V2のschema/validatorは存在するが、benchmark workflowへの配線は未実装。

    Outcome

    • 専用benchmark modeでpython_test_job_total_msを測定する。
    • base/head各20 runを同一cohort fingerprintで比較する。
    • benchmark modeではartifactの存在、schema、sample数、run ID、cohort一致をfail-closeで検証する。
    • 既存CI_TEST_PERFORMANCE_ASSESSMENT_V2を生成・検証し、性能主張を機械判定する。
    • 通常PRのoptional telemetryとbenchmark時のrequired evidenceを分離する。

    Metric Boundary

    python_test_job_total_ms =
      first_required_execution_step.started_at
      → final_required_evidence_step.completed_at
    

    Required Cohort Fingerprint

    runner_image:
    runner_arch:
    python_version:
    uv_version:
    pytest_version:
    xdist_version:
    workers:
    scheduler:
    python_test_plan_digest:
    lockfile_digest:
    workflow_digest:
    action_resolved_revisions:
    codex_version:

    Acceptance Criteria

    • AC1: benchmark専用workflow_dispatchまたは明示inputが存在する
    • AC2: job totalの開始・終了境界がmachine-readableに定義される
    • AC3: pytest phaseとjob totalの双方をartifactへ保存する
    • AC4: base/head各20件未満、run ID重複、runner cohort不一致を拒否する
    • AC5: plan/lockfile/workflow digest不一致をincomparable cohortとして扱う
    • AC6: benchmark modeではupload前にtest -sとschema validatorを実行する
    • AC7: benchmark modeのuploadがif-no-files-found: errorである
    • AC8: normal CIではoptional telemetryとして継続可能である
    • AC9: CI_TEST_PERFORMANCE_ASSESSMENT_V2を既存validatorで検証する
    • AC10: improvement claimではP50改善かつP95非退行を要求する
    • AC11: run ID、cohort fingerprint、P50/P95、deltaをcommitted summaryへ記録する
    • AC12: artifact欠落、重複run、stale SHA、sample不足のnegative testを持つ

    Out of Scope

    • CI_TEST_PERFORMANCE_ASSESSMENT_V2 schemaの再設計
    • pytest schedulerの再選定
    • unrelated CI jobの性能最適化
    • GitHub-hosted runnerの種類変更

    Allowed Paths

    • .github/workflows/ci.yml
    • .github/workflows/ci-python-test-benchmark.yml
    • scripts/ci/
    • scripts/ci/tests/
    • docs/dev/ci-performance.md
    • docs/dev/ci-runtime-baseline-*.md
    • .claude/skills/ci-test-performance/SKILL.md
    
    ## 推奨順序
    
    #1059には最終closure evidenceを投稿してCloseし、後継は **#1725 → Issue案1 → Issue案2 → Issue案3 → Issue案4 → Issue案5** の順が妥当です。Issue案4はjob構成とplan schemaが安定してからparity invariantを固定し、Issue案5は最終的なjob境界が確定してからbenchmarkを取る必要があります。
    
  7. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    Parent Closure Verification(control-plane 独立検証)

    OWNER の判定(PARENT_CLOSURE_VERIFICATION_V1 案)を、以下すべて git / gh の実コマンドで独立に再検証した。

    PARENT_CLOSURE_VERIFICATION_V1:
      parent_issue: 1059
      verified_at: "2026-07-26T00:57:05Z"
      current_main_sha: "aa07986b250ba86d5324fa1ea2f173b82824bc57"
    
      ac1_child_delivery:
        - issue: 1060
          close_reason: completed
          closing_pr: 1078
          merged: true
          merge_commit_sha: 7b8167774a16d5506dbb88670f3b68b75b22053a
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - docs/dev/test-lane-policy.md
            - .claude/skills/ci-test-performance/SKILL.md
    
        - issue: 1061
          close_reason: completed
          closing_pr: 1121
          merged: true
          merge_commit_sha: db86c058f2c18d4c9abeb06f074ed814fcfc44ec
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - .github/workflows/ci.yml
            - docs/dev/ci-performance.md
          note: "PR #1121 の GitHub 上の closingIssuesReferences は #1123 のみを指す(#1061 は同一 merge commit を参照して手動 close, stateReason=COMPLETED)。実体としては同一コミットで両方解消されているが、GitHub の自動 close-link だけを機械的信頼源にする場合はこの乖離に注意"
    
        - issue: 1063
          close_reason: completed
          closing_pr: 1129
          merged: true
          merge_commit_sha: f2ee8f662add514fe531fcc1a2bad81405c62f97
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - pyproject.toml
    
        - issue: 1064
          close_reason: completed
          closing_pr: 1151
          merged: true
          merge_commit_sha: 54858e277144d670eb2b24a1f96d82515f295c87
          merge_commit_is_main_ancestor: true
          required_paths_present:
            - .github/ci/python-test-plan.json
            - .github/workflows/ci.yml
    
      ac2_performance:
        metric_scope: python_pytest_total_ms
        formula: pytest_parallel_ms + pytest_serial_ms
        runner_image: ubuntu24/20260615.205.1
        base_runs: 20
        head_runs: 20
        base_p50_ms: 221130.5
        head_p50_ms: 77882.0
        base_p95_ms: 228195.5
        head_p95_ms: 80564.4
        p50_improved: true
        p95_improved: true
        evidence: docs/dev/ci-runtime-baseline-1064.md
        evidence_verified: true
    
      ac3_current_main:
        pnpm_typecheck: pass
        pnpm_test: "pass (100 files / 1801 tests)"
        pnpm_build: pass
        verification_method: "現行 main (aa07986b) をローカルで checkout 済み状態で pnpm typecheck / pnpm test / pnpm build を直接実行(main branch 直 push 用の `ci` workflow run が GitHub Actions 上に存在しないため、GitHub Actions run ID の参照ではなくローカル実行結果を証跡とする)"
    
      decision: close_ready

    独立検証で見つかった軽微な訂正

    OWNER 案の closing_pr: 1121(issue 1061 向け)について、GitHub の closingIssuesReferences API は PR #1121 が自動的に close するのは #1123 のみであることを示している。#1061 は同一の merge commit (db86c058...) を参照して手動で completed close されている。実質的な解消内容(same commit)は一致しており false positive ではないが、機械的な close-link だけに依拠する将来の自動検証ロジックでは、この「手動 close + 同一 commit 参照」パターンも正当な completion として扱えるようにする必要がある。

    結論

    上記すべての項目を独立に確認し、decision: close_ready を支持する。本 Issue を completed として close する。

  8. changed the title [-]CI python-test 高速化: test lane 分離・pytest 統合・Ruff 導入・Skill 化[/-] [+]CI python-test pytest実行phase高速化: test lane分類・pytest統合・Ruff導入・Skill化[/+] on Jul 25, 2026
  9. squne121 commented on Jul 25, 2026

    @squne121
    OwnerAuthor

    Parent Closure Verification 完了(control-plane独立検証済み、上記コメント参照)。全child mergeを確認し AC1-AC3 を満たしたためCloseする。

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

    tracking

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions