Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "PR #2172(Closes #2159)で構築した e2e performance benchmark 測定器の rerun-attempt 選択を、OWNER adversarial review P1-1 の指摘どおり決定論的にする"
change_kind: codeRuntime Verification Applicability
- decision: not_applicable
- reason: 本 Issue は collector / performance gate の選択ロジックとスキーマ更新のみを対象とする純粋な静的変更であり、プロセス起動・外部通信・UI 操作は不要。
uv run --locked pytestによるユニット/回帰テストとrgによる doc grep のみで検証が完結する。
Parent Issue
なし(単独 follow-up。起点は PR #2172 / originating Issue #2159)
Parent Goal Ref
- Goal:
scripts/ci/collect_e2e_performance_benchmark.py::_dedupe_by_workflow_run_idおよびtests/ci/test_ci_performance_gate.py内の同種選択ロジックの rerun attempt 選択を、入力配列の並び順に依存しない決定論的なものにする - Desired Destination: N/A(単独改善のため親 Issue のスコープなし)
Current Validated Scope
scripts/ci/collect_e2e_performance_benchmark.pyの_dedupe_by_workflow_run_id(または同等の選択ロジック)を order-independent 化するtests/ci/test_ci_performance_gate.py(production performance gate としてrun_evidence_gate()から使用される)の_dedupe_by_workflow_run_id/_pair_by_workflow_run_id/_cli_run_details_from_pairsを同じ決定論的ポリシーで order-independent 化し、"run_attempt": 1のハードコードを廃止する- 選択した
run_attemptと選択ポリシー(initial_attempt_only_v1に固定)を manifest 出力・gate assessment の双方に記録する schemas/e2e_performance_benchmark_manifest_v1.schema.jsonのRunRecord(unevaluatedProperties: false)にrun_attempt/rerun_attempt_selection_policyを後方互換な optional field として追加するrun_attemptを_verify_run_record()経由で trusted evidence に binding し、(workflow_run_id, job, run_attempt)の型/衝突を fail-closed で扱うscripts/ci/tests/e2e_performance_benchmark/およびtests/ci/に順序違いの回帰テストを追加する
Remaining Parent Gaps
なし
Outcome
scripts/ci/collect_e2e_performance_benchmark.py::_dedupe_by_workflow_run_id と tests/ci/test_ci_performance_gate.py 内の同種選択ロジック(_dedupe_by_workflow_run_id / _pair_by_workflow_run_id / _cli_run_details_from_pairs)の両方が、initial_attempt_only_v1 ポリシー(workflow_run_id ごとに run_attempt == 1 の成功レコードのみを候補とし、attempt 1 が失敗/欠落しているサンプルは除外する。入力配列内の出現順序には一切依存しない)に基づいて決定論的に選択を行うようになり、選択した run_attempt の値とポリシー識別子が manifest 出力・gate assessment の双方に記録された状態。run_attempt の値は artifact に紐づく GitHub API の attempt-specific jobs レスポンスと照合される。同一 underlying record 集合を異なる挿入順序で与えても、選択結果と runs の出力順序(workflow_run_id 昇順の canonical sort)が完全に一致することを検証する回帰テストが追加され、uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark.py と uv run --locked pytest tests/ci/test_ci_performance_gate.py が全件 PASS すること。
In Scope
_dedupe_by_workflow_run_id(collector 側・gate 側の両方、または名称変更後の同等関数)を、dict.setdefault()による first-seen-wins(挿入順依存)から、initial_attempt_only_v1ポリシー(run_attempt == 1かつ success のレコードのみを候補にする。attempt 1 が存在しない/失敗している場合はそのworkflow_run_idのサンプル自体をスキップする)へ変更する。現行の「non-success record を除外した後で dedupe する」順序では attempt-1-only を実現できないため、dedupe/filter の順序を見直すtests/ci/test_ci_performance_gate.pyの_pair_by_workflow_run_id()(dict comprehension による実質 last-seen-wins)を同じポリシーに統一し、_cli_run_details_from_pairs()にハードコードされている"run_attempt": 1を、実際に選択された attempt 値を伝播する実装に置き換える- 選択された
run_attemptの値と選択ポリシー識別子(rerun_attempt_selection_policy: "initial_attempt_only_v1")を manifest の該当 run エントリまたは job cohort に記録する。schemas/e2e_performance_benchmark_manifest_v1.schema.jsonのRunRecord(unevaluatedProperties: false)にrun_attempt(integer >= 1)とrerun_attempt_selection_policy(string)を、既存 manifest との後方互換性を維持する optional field として追加する run_attemptを trusted な必須フィールドとして扱い、_verify_run_record()の live verification 経路で attempt-specific jobs API(GET .../actions/runs/{run_id}/attempts/{attempt_number}/jobs相当)と突き合わせて binding する。artifact payload 内の attempt 値と API 側 attempt 値が矛盾する場合は fail-closed でconflict扱いにする- selection 後の
runs配列をworkflow_run_id(必要なら(workflow_run_id, job, run_attempt))の固定キーでソートし、異なるworkflow_run_id間の出力順序も入力順に依存しないようにする - live artifact 取得(
GET .../actions/runs/{run_id}/artifacts)が pagination されている場合に全ページを走査するようにする(現状は1ページのみ取得しており、rerun 回数が多い run で存在する artifact をartifact_not_foundと誤判定し得る) run_attemptの入力契約をinteger >= 1に正規化し、missing / 文字列型(例:"2")/0/ 負値 / 同一(workflow_run_id, job, run_attempt)で artifact ID・digest が異なる衝突を、すべて fail-closed のテストケースとして扱うdocs/dev/e2e-performance-benchmark.mdの「サンプル identity:workflow_run_id」節に、initial_attempt_only_v1ポリシーの説明(attempt 1 失敗時はサンプル除外・新規 run で再取得する運用)を追記する- 同一 underlying record 集合を異なる挿入順序・iteration 順序で与えた場合に、選択結果と出力順序の両方が完全に一致することを確認する回帰テストを
scripts/ci/tests/e2e_performance_benchmark/とtests/ci/に追加する
Out of Scope
initial_attempt_only_v1以外の選択ポリシー(常に最新成功 attempt を採用する等)の検討・実装。本 Issue では OWNER レビューの推奨に基づきinitial_attempt_only_v1に固定する- PR fix: e2e performance benchmark の fixed-SHA cohort・paired critical path・cross-run collector・immutable manifest を再設計する #2172 で実装済みの他の測定器ロジック(artifact 検証、percentile 計算、fingerprint 分類等)のうち、rerun attempt 選択と無関係な部分の変更
- CI ワークフロー側での実際の rerun 運用ポリシー変更(このリポジトリの
.github/workflows/*.ymlトリガー条件変更等) schemas/e2e_performance_benchmark_manifest_v1.schema.jsonをmanifest_v2として分離すること(v1 の後方互換 optional field 拡張で対応する)schemas/ci_test_reliability_assessment_v1.schema.json(実装: CI reliability assessment(failure/flaky rate)の versioned schema と raw-attempt 基準の validator を新設する(Issue B) #2170)側のrequired_run_attempt契約そのものの変更(reliability 側は既存のまま。参考にするのみ)
Acceptance Criteria
- AC1: collector 側
_dedupe_by_workflow_run_id(scripts/ci/collect_e2e_performance_benchmark.py)が、同一workflow_run_idを持つ複数レコードに対して、入力リストの並び順を変えても常に同一のレコードを選択する(順序非依存性)。回帰テストは新規ファイルscripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.pyに追加する - AC2: gate 側
_dedupe_by_workflow_run_id/_pair_by_workflow_run_id(tests/ci/test_ci_performance_gate.py)も同じinitial_attempt_only_v1ポリシーで順序非依存になっており、_cli_run_details_from_pairs()のrun_attempt: 1ハードコードが実際の選択結果を伝播する実装に置き換わっている。回帰テストは既存の兄弟ファイル命名規則(test_ci_performance_gate_*.py)に従う新規ファイルtests/ci/test_ci_performance_gate_rerun_attempt_selection.pyに追加し、tests/ci/test_ci_performance_gate.pyから helper をインポートする - AC3: 選択ポリシーが
initial_attempt_only_v1という単一の明示的なルールとしてコード内に記述されており、dict.setdefault()の挿入順依存(first-seen-wins)にも_pair_by_workflow_run_id()の dict comprehension による実質 last-seen-wins にも依存していない - AC4: 選択された
run_attemptの値がschemas/e2e_performance_benchmark_manifest_v1.schema.jsonのRunRecord(既存 manifest との後方互換性を維持する optional field として追加されたrun_attempt/rerun_attempt_selection_policy)に準拠する形で manifest 出力(または対応する job cohort エントリ)に記録され、schema validation を通過する - AC5:
run_attemptが live verification 経路で attempt-specific jobs API 相当の trusted evidence と照合され、artifact payload 側の attempt 値と矛盾する場合に fail-closed で検出される回帰テストが追加されている - AC6: 採用した選択ポリシー(
initial_attempt_only_v1)の名前・理由・attempt 1 失敗時のサンプル除外運用がdocs/dev/e2e-performance-benchmark.mdに明記されている - AC7: 同一 underlying record 集合を複数の異なる挿入順序(例: 元の順序 / 逆順 / シャッフル順)で与えるパラメタライズド回帰テストが
scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.pyおよびtests/ci/test_ci_performance_gate_rerun_attempt_selection.pyに追加されており、全順序で出力(選択されたレコード、run_attempt、runs配列の canonical sort 順)が完全に一致することを検証している - AC8: artifact 一覧取得の pagination を全ページ走査するテスト(複数ページに跨る artifact が正しく発見されることを検証する回帰テスト)が
scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.pyに追加されている - AC9:
run_attemptの型正規化・欠落・衝突(missing / 文字列型 /0/ 負値 / 同一キーで artifact ID・digest が異なる衝突)が fail-closed で検出される回帰テストがscripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.pyに追加されている - AC10: 既存の
test_collect_e2e_performance_benchmark.pyとtest_ci_performance_gate.pyの全テストが引き続き PASS する
Verification Commands
# AC1
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_dedupe_by_workflow_run_id_order_independent
# AC2
$ uv run --locked pytest tests/ci/test_ci_performance_gate_rerun_attempt_selection.py::test_dedupe_and_pair_by_workflow_run_id_order_independent
# AC3
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_selection_policy_is_initial_attempt_only_v1
# AC4
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_run_attempt_recorded_schema_conformant
# AC5
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_run_attempt_trusted_binding_conflict_fails_closed
# AC6
$ rg -n "initial_attempt_only_v1" docs/dev/e2e-performance-benchmark.md
# AC7
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_order_independent_parametrized_matches_canonical_sort
$ uv run --locked pytest tests/ci/test_ci_performance_gate_rerun_attempt_selection.py::test_order_independent_parametrized_matches_canonical_sort
# AC8
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_artifact_listing_paginates_all_pages
# AC9
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py::test_run_attempt_type_normalization_and_conflict_fail_closed
# AC10
# baseline-expect: pass
$ uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark.py
# baseline-expect: pass
$ uv run --locked pytest tests/ci/test_ci_performance_gate.pyAllowed Paths
scripts/ci/collect_e2e_performance_benchmark.pyscripts/ci/tests/e2e_performance_benchmark/docs/dev/e2e-performance-benchmark.mdschemas/e2e_performance_benchmark_manifest_v1.schema.jsontests/ci/test_ci_performance_gate.pytests/ci/test_ci_performance_gate_rerun_attempt_selection.py(新規ファイル。既存の兄弟ファイル命名規則に従う)
Stop Conditions
schemas/e2e_performance_benchmark_manifest_v1.schema.jsonの後方互換 optional field 拡張だけでは表現できない破壊的スキーマ変更が必要と判明した場合(manifest_v2への分離が必要と判明した場合は直ちに停止して報告する)tests/ci/test_ci_performance_gate.py/tests/ci/test_ci_performance_gate_rerun_attempt_selection.py以外の performance gate 関連ファイル(tests/ci/test_ci_performance_gate_clock_alignment.py等の既存兄弟ファイル)への変更が必須と判明した場合- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
なし
Required Design References
- docs/dev/e2e-performance-benchmark.md
- schemas/e2e_performance_benchmark_manifest_v1.schema.json
- schemas/ci_test_reliability_assessment_v1.schema.json(実装: CI reliability assessment(failure/flaky rate)の versioned schema と raw-attempt 基準の validator を新設する(Issue B) #2170 の
required_run_attempt契約を参考にする。変更対象ではない)
Scope Delta(任意)
- 起点: OWNER REQUEST_CHANGES コメント(https://github.com/squne121/loop-protocol/issues/2179#issuecomment-5301621365)
- 追加した Allowed Paths:
schemas/e2e_performance_benchmark_manifest_v1.schema.json(AC3/Allowed Paths 自己矛盾の解消。現行RunRecordがunevaluatedProperties: falseでrun_attemptを許可していないため)、tests/ci/test_ci_performance_gate.py(collector だけでなく production performance gate 側にも同型の順序依存バグがあり、run_attempt: 1がハードコードされているため、放置すると 検証: #2119 AC9/AC10 の close-grade 実CI証跡を確認する #2155 の close 判定が非決定論的なままになる)、tests/ci/test_ci_performance_gate_rerun_attempt_selection.py(新規テストファイル。既存ファイルへ::新規test名で追加すると VC の非正規形状として blocker になるため、既存の兄弟ファイル命名規則に従う新規ファイルへ分離した) - 追加/変更した AC: AC2(gate 側の順序依存修正)、AC5(
run_attemptの trusted binding)、AC8(artifact pagination)、AC9(型/衝突正規化)を新設。AC3〜AC7・AC10 は既存 AC の対象を gate 側にも拡張する形で改訂 - 変更した In Scope: 選択ポリシーを「実装時に決定」から
initial_attempt_only_v1に固定(OWNER 推奨に基づく)。dedupe/filter の順序見直し・canonical sort・trusted binding・pagination を追加 - non_conflict_reason: 追加された 2 パスは既存の overlap candidate(実装: playtest-log の JSON Schema / validator の追加 #420 / 改善: VC 設計ガイドラインに否定パターン誤マッチ防止チェックを追加 #237 / 実装: rate limit / API error 由来の停止を StopFailure hook でログ保存し resume playbook を整備する #225 / 改善: executable bit audit CI guard の適用範囲を .claude/skills 外のスクリプトへ拡張する #213 / 実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205)とは無関係で、OWNER コメントが明示的に指摘した具体ファイルのみを対象とする
Background
PR #2172(https://github.com/squne121/loop-protocol/pull/2172、merged to main as commit af47ed7、Closes #2159)で e2e performance benchmark 測定器を実装した。OWNER adversarial review(https://github.com/squne121/loop-protocol/pull/2172#issuecomment-5295659213)で finding P1-1 が指摘され、PR 本文に follow-up として明記の上、当該 PR ではスコープ外として明示的に見送られた。
P1-1: rerun attempt selection is input-order dependent. GitHub の GITHUB_RUN_ID は rerun しても変わらないが GITHUB_RUN_ATTEMPT は増分する(1, 2, 3...)。現在の _dedupe_by_workflow_run_id(scripts/ci/collect_e2e_performance_benchmark.py)は setdefault() による first-seen-wins セマンティクスを使っており、どの attempt が canonical として扱われるかが入力 JSON / API レスポンスでレコードがたまたま出現する順序に依存してしまう。固定の宣言されたポリシーではない。
本 Issue の初回起票版に対して OWNER が REQUEST_CHANGES レビュー(上記 issuecomment-5301621365)を行い、以下の欠陥を指摘した。
- P0: 初回契約は AC3(
run_attemptを manifest に記録)と Allowed Paths が自己矛盾していた(schemas/e2e_performance_benchmark_manifest_v1.schema.jsonがunevaluatedProperties: falseでrun_attemptを許可していないのに、schema ファイルが Allowed Paths 外だった)。→ 本改訂で schema ファイルを Allowed Paths に追加し、後方互換 optional field として拡張する方針を明記した。 - P0: collector だけを修正しても、
tests/ci/test_ci_performance_gate.py(run_evidence_gate()から production gate として使用される)に同型の順序依存バグとrun_attempt: 1のハードコードが残り、検証: #2119 AC9/AC10 の close-grade 実CI証跡を確認する #2155(この performance gate を実 CI データで実行して 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 の close 可否を決める downstream Issue)の判定が非決定論的なままになる。→ 本改訂で gate 側ファイルを scope に含めた。 - P0:
run_attemptを単純に追加してmin()/max()すると、正しい artifact に偽のrun_attemptを付けるだけで canonical selection を操作できてしまう(trusted binding が欠如)。→ 本改訂で attempt-specific jobs API との binding を AC5 として追加した。 - P0: 「具体的な selection policy は実装時に決める」は契約として弱く、job 単位の rerun により同一 workflow_run_id 内で実際には同時実行されていない job 同士を合成しうる。また現行の「non-success 除外後に dedupe」の順序では attempt-1-only を実現できない。→ 本改訂でポリシーを
initial_attempt_only_v1に固定し、dedupe/filter の順序見直しを In Scope に追加した。 - P1: 異なる
workflow_run_id間の出力順序が入力順のままで、AC5(旧)が意図する完全な order independence を保証できない。→ 本改訂で canonical sort を AC7 として追加した。 - P1: live artifact 取得が pagination に対応しておらず、rerun を多用した run で存在する artifact を誤検出し得る。→ 本改訂で AC8 として追加した。
- P1:
run_attemptの型・重複衝突契約が未定義。→ 本改訂で AC9 として追加した。
Source
source_kind: post_merge_cleanup
source_url: "https://github.com/squne121/loop-protocol/pull/2172"
dedupe_key: "follow-up:squne121/loop-protocol:pr/2172:performance-benchmark-p1-1-rerun-dedup"Delivery Rule
1 Issue = 1 PRを原則とする- 作業は専用 worktree で行い、Draft PR を既定とする
Notes for Reviewer
- overlap preflight(
check_issue_overlap.py)は初回起票時にdecision: overlap_requires_comment(policy_class C1)を返した。candidate は 実装: playtest-log の JSON Schema / validator の追加 #420 / 改善: VC 設計ガイドラインに否定パターン誤マッチ防止チェックを追加 #237 / 実装: rate limit / API error 由来の停止を StopFailure hook でログ保存し resume playbook を整備する #225 / 改善: executable bit audit CI guard の適用範囲を .claude/skills 外のスクリプトへ拡張する #213 / 実装: .claude/skills 配下スクリプトの executable bit を監査し CI guard を追加する #205(いずれも OPEN)。 - non_conflict_reason: これらの candidate は
scripts/testsのような広い bare Allowed Paths を宣言している既存 Issue であり、本 Issue が対象とする具体パス(scripts/ci/collect_e2e_performance_benchmark.py等)と文字列レベルで重なっているだけで、実際の編集意図(playtest-log schema、VC ガイドライン等)は本 Issue のスコープと無関係。 - edit_intent: 本 Issue は
_dedupe_by_workflow_run_id系の rerun-attempt 選択ロジック(collector・gate 双方)と、それに付随する manifest schema 拡張のみを対象とし、上記 candidate と実質的な作業内容の競合はない。 - 実 Git conflict は worktree/PR 作成時に別途検出される(導入: AIエージェント運用をminimal harnessへ縮退し、過剰なcontrol-planeを廃止する #1860 Owner Decision に基づき起票停止理由にしない)。
- 本改訂は issue-refinement-loop(自律実行、人間承認省略)が OWNER の REQUEST_CHANGES コメント(issuecomment-5301621365)を反映して行った。VC は
-kkeyword フィルタが未実装テストで exit 5(no tests collected、hard block)を返す既知の落とし穴を避けるため、未作成の具体テスト関数を::test_nameで参照する形式に修正したが、既存ファイルへの::新規test名追加も別途 VC の非正規形状(Issue 実装: VC baseline-fail 用 pytest command を canonical form に正規化して contract-review 往復を削減する #1285 / PR feat: VC baseline-fail pytest command を canonical form に正規化する compiler を追加 #1305)として blocker になったため、新規テストは未作成の専用ファイル(test_collect_e2e_performance_benchmark_rerun_attempt.py/test_ci_performance_gate_rerun_attempt_selection.py)に配置する形へ再修正済み(exit 4=collection error=expected baseline fail として扱われる canonical shape)。AC10 は既存テストの regression-safety チェックであり# baseline-expect: passを付与している。
Activity
squne121 commentedon Aug 15, 2026
Verdict:
REQUEST_CHANGESIssue #2179 の問題設定自体は妥当です。PR #2172 で defer された P1-1、すなわち「同じ
workflow_run_idの rerun のうち、入力順で canonical record が変わる」という欠陥を正しく拾っています。現行 collector も実際にdict.setdefault()の first-seen-wins です。ただし、現在の Issue 契約のまま実装すると、局所的には AC が通っても、実 benchmark / #2155 の close gate 全体では rerun attempt が決定論的にならない可能性が高いです。実装開始前に Issue 本文を修正すべきです。
P0 — AC3 と Allowed Paths が自己矛盾しており、そのままでは実装不能です。 Issue は「選択した
run_attemptと選択ポリシーを manifest に記録」を In Scope/Outcome に置き、AC3 でもrun_attemptの manifest 記録を要求しています。一方、現行RunRecordschema はunevaluatedProperties: falseで、許可フィールドにrun_attemptも selection policy もありません。したがって単純に collector がフィールドを足すと schema validation に失敗します。ところが schema ファイルは Allowed Paths 外であり、「schema 変更が必要なら停止」が Stop Condition です。修正:
schemas/e2e_performance_benchmark_manifest_v1.schema.jsonを Allowed Paths に加え、schema evolution を Issue 内で決定してください。新フィールドを必須契約化するならmanifest_v2を切る方が明瞭です。v1 を拡張するなら「既存 manifest との互換性を維持する optional field とする」などを明示すべきです。また In Scope が要求する「selection policy 名/理由を manifest に記録」は、現 AC では検証されていません。schema-conformant manifest に policy identifier が存在することを独立 AC/VC にしてください。P0 — collector だけ修正しても、実際の performance gate に別の順序依存実装が残ります。
tests/ci/test_ci_performance_gate.py::_dedupe_by_workflow_run_id()も first-seen-wins です。さらに_pair_by_workflow_run_id()は dict comprehension で同一 ID の重複に対して実質 last-seen-wins となっています。しかもrun_evidence_gate()はこの pairing を production gate として使い、_cli_run_details_from_pairs()は実際に選ばれた attempt と無関係にrun_attempt: 1をハードコードしています。検証: #2119 AC9/AC10 の close-grade 実CI証跡を確認する #2155 はまさにこの
tests/ci/test_ci_performance_gate.pyを実 CI データで実行して 実装: CI: Playwright E2E の responsive matrix を専用 lane へ分離し critical path を短縮する #2119 の close 可否を決める downstream Issue です。つまり 実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする #2179 の Allowed Paths のままでは、collector の manifest だけ決定論的になり、最終判定経路は非決定論的なままです。修正:
tests/ci/test_ci_performance_gate.pyと対応 regression test を 実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする #2179 の scope に含めるか、rerun canonicalization を shared production helper に切り出して collector/gate の双方から使ってください。assessment のrun_details[].run_attemptも選択結果を伝播させ、1の捏造は廃止する必要があります。P0 — 新しい選択キー
run_attemptが trusted GitHub evidence に binding されません。 現 collector の_verify_run_record()はrun_attemptを検査しておらず、live verification も run の artifact 一覧からartifact_id/ digest /workflow_run.id/head_shaを照合するだけです。 GitHub の artifact REST response 自体にもrun_attemptは含まれていません。([GitHub Docs]1)したがって、今の設計に単に
run_attemptを追加してmin()/max()すると、正しい artifact に偽のrun_attemptを付けるだけで canonical selection を操作できます。GitHub はrun_id + attempt_numberを指定して、その attempt に属する jobs を取得する公式 API を提供しています。([GitHub Docs]2)修正:
run_attemptをint >= 1の必須 trusted field にし、attempt-specific jobs API で少なくとも job 名・head SHA・conclusion と binding してください。artifact payload 内の attempt と API attempt の照合も行うとさらに堅牢です。P0 — 「具体的な selection policy は実装時に決める」は benchmark 契約として弱すぎます。 GitHub では
GITHUB_RUN_IDは同一 workflow run の identity で、GITHUB_RUN_ATTEMPTは 1 から rerun ごとに増えます。([GitHub Docs]3) さらに rerun は「全 job」だけでなく「失敗 job だけ」「特定 job だけ」が可能です。([GitHub Docs]4)そのため post-split benchmark で
e2e-coreは attempt 1、e2e-responsive-matrixは attempt 2 をそれぞれ「最新成功」として選ぶと、実際には同時実行されていない二つの job を同一 workflow_run_id の paired critical path として合成することができます。これは 実装: e2e performance benchmark の fixed-SHA cohort・paired critical path・cross-run collector・immutable manifest を再設計する(Issue A) #2159 で導入した exact-pairing の意味を壊します。加えて collector は現在、non-success record を除外した後で dedupe しています。したがって Issue が例示している
attempt-1-onlyを選ぶ場合、attempt 1 が failure・attempt 2 が success なら、dedupe に到達した時点では attempt 1 が消えており、attempt-1-only を実現できません。修正: policy は OWNER contract として Issue 上で固定してください。実装者に統計的サンプリング規則を決めさせるべきではありません。
P1 — 最小/最大 attempt を決めても、manifest 全体の order independence は成立しません。 現
_dedupe_by_workflow_run_id()は最後にlist(seen.values())を返すため、異なるworkflow_run_id間の順序は入力の初出順のままです。その list がそのまま manifest のrunsへ書かれます。AC5 が意図する「同一 underlying record 集合なら output が完全一致」を本当に保証するには、winner を決めるだけでなく、canonical output ordering が必要です。
修正: selection 後に
workflow_run_id、必要なら(workflow_run_id, job, run_attempt)の固定 key で sort してください。テストでは「duplicate attempt の順序」だけでなく「別 workflow_run_id 同士の順序」も permutation してください。P1 — artifact pagination が rerun policy と衝突します。 現 live verifier は
GET .../actions/runs/{run_id}/artifactsを1回だけ取得しています。 GitHub の当該 endpoint は既定 30 件/page、最大 100 件/page で pagination されます。([GitHub Docs]1) 一方 workflow run は最大 50 回 rerun でき、特定 job だけの rerun もできます。([GitHub Docs]4)したがって rerun を多用した run では、特に「最古 attempt」を選ぶ policy の artifact が page 2 以降へ落ち、存在する artifact を
artifact_not_foundと誤判定できます。修正: artifact lookup は全 page を traverse するか、artifact name/id を使った確実な lookup に変更し、page 2 以降の regression test を追加してください。
P1 —
run_attemptの型・重複衝突契約が不足しています。 現在の collector test fixture_record()自体にrun_attemptがなく、既存 rerun test も同じworkflow_run_idに別artifact_idを入れて「2件になること」しか検証していません。どちらの record が canonical になるべきかはテストしていません。 一方、実 workflow の baseline producer は${{ github.run_attempt }}を environment variable 経由で Python に渡しており、artifact 内では文字列として書かれます。修正: collector の canonical input contract を
run_attempt: integer >= 1と明記し、boundary で正規化してください。missing /"2"/0/ negative / 同じ(workflow_run_id, job, run_attempt)なのに artifact ID/digest が異なる conflict をすべて fail-closed test にするべきです。同じ attempt 番号の相異なる record に対して単純なmin()を使うと、再び入力順依存になります。採るべき selection policy
この benchmark では
initial_attempt_only_v1を第一候補にするのが最も一貫しています。つまりworkflow_run_idを独立 sample とし、run_attempt == 1だけを候補にする。attempt 1 が失敗・不完全なら、その workflow run は performance sample から除外し、新しいworkflow_dispatchrun を1サンプルとして起動する方式です。これは GitHub の rerun が full workflow とは限らず specific job の再実行にもなり得ることから、attempt を跨いだ synthetic pair を原理的に防ぎます。([GitHub Docs]4) Repository 内でも reliability 側の #2170 は
workflow_run_idを sample identity としrequired_run_attempt: 1、rerun を介入として別扱いする契約を採っています。performance と reliability が必ず同じ規則である必要はありませんが、rerun semantics は metric contract で宣言するものという先例にはなっています。どうしても rerun を performance sample として救済したいなら、
latest-successful-per-jobは避け、全 required jobs が同一 attempt に揃った「単一 complete attempt」を workflow_run 単位で選ぶ必要があります。その場合は collector の job ごとの dedupe より上位で attempt selection を行わなければなりません。Issue #2179 を実装可能な契約にするなら
最小でも、schema を Allowed Paths に追加し、policy を
initial_attempt_only_v1等に固定し、run_attemptを trusted API evidence に binding し、tests/ci/test_ci_performance_gate.pyまで scope に入れ、manifest のrunsを canonical sort するところまで必要です。また manifest にはrun_attemptだけでなくrerun_attempt_selection_policyのような versioned identifier を記録し、assessment まで実際の attempt を伝播させるべきです。現状の #2179 は「局所的な
setdefault()修正 Issue」としては成立していますが、「PR #2172 P1-1 を解消した」と主張できる契約にはなっていません。 特に P0 の3点――schema/Allowed Paths 矛盾、production gate 側の別 selector、run_attemptの provenance 未検証――を直してから refinement/implementation に回すのが妥当です。squne121 commentedon Aug 15, 2026
issue-refinement-loop 終了報告
REVIEWED_BODY_SHA256: sha256:eddd7fb85e0ee8bb7116f04de49f815b871e637ee9a3e86383026ec1652eba01、BLOCKERS: 0)-kkeyword フィルタが未実装テストで exit5 hard-block になる落とし穴を修正、3回目: 既存ファイルへの::新規test名追加が非正規 VC 形状のため新規テストファイルへ分離)起点
anchor comment: https://github.com/squne121/loop-protocol/issues/2179#issuecomment-5301621365(OWNER squne121 による REQUEST_CHANGES)
反映した主な変更
schemas/e2e_performance_benchmark_manifest_v1.schema.jsonとtests/ci/test_ci_performance_gate.py/tests/ci/test_ci_performance_gate_rerun_attempt_selection.py(新規)を追加(AC3/Allowed Paths 自己矛盾の解消、production performance gate 側の同型バグを scope に含める)initial_attempt_only_v1に固定(OWNER 推奨)run_attemptの trusted binding(AC5)、canonical sort(AC7)、artifact pagination(AC8)、型/衝突正規化(AC9)を新設## Runtime Verification Applicabilityセクションを追加(decision: not_applicable)issue-refinement-loop(自律実行、人間承認省略)は本 Issue の contract を review-approve 済みの状態にした。次段階は
issue-contract-reviewの実行である。squne121 commentedon Aug 15, 2026
implement-issue: 実装完了 (2026-08-15T12:39:57Z)
.claude/worktrees/issue-2179-rerun-attempt-selectionworktree-issue-2179-rerun-attempt-selectionsqune121 commentedon Aug 15, 2026
impl-review-loop: 完了 (2026-08-15T13:05:00Z)
squne121 commentedon Aug 15, 2026
impl-review-loop: 完了 (2026-08-15T13:03:00Z)
fix: e2e performance benchmark の rerun attempt 選択を OWNER review の指摘どお…
squne121 commentedon Aug 15, 2026
impl-review-loop: 完了 (2026-08-15T14:35:00Z)
fix: e2e performance benchmark の rerun attempt 選択を決定論的にする (#2182)