Skip to content

fix: e2e performance benchmark の rerun attempt 選択を決定論的にする - #2182

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2179-rerun-attempt-selection
Aug 15, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2179-rerun-attempt-selection

Conversation

@squne121

@squne121 squne121 commented Aug 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • PR fix: e2e performance benchmark の fixed-SHA cohort・paired critical path・cross-run collector・immutable manifest を再設計する #2172(squne121/loop-protocol#2172、実装: e2e performance benchmark の fixed-SHA cohort・paired critical path・cross-run collector・immutable manifest を再設計する(Issue A) #2159 をクローズ済み)で実装した e2e performance benchmark 測定器の rerun-attempt 選択ロジックを、OWNER adversarial review(issuecomment-5295659213 P1-1)の指摘どおり決定論的に修正する。
  • 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 の両方を、dict.setdefault() の first-seen-wins および dict 内包表記の実質 last-seen-wins(いずれも入力配列の並び順に依存する挙動)から、単一の明示的な initial_attempt_only_v1 ポリシー(run_attempt == 1 の成功レコードのみを候補とし、attempt 1 が失敗/欠落しているサンプルはそのまま cohort から除外する。他の attempt へフォールバックしない)へ置き換えた。
  • 選択した run_attempt の値と選択ポリシー識別子(rerun_attempt_selection_policy: "initial_attempt_only_v1")を manifest の RunRecord(後方互換 optional field)に記録し、run_attempt を live attempt-specific jobs API(GET .../actions/runs/{run_id}/attempts/{attempt_number}/jobs)と突き合わせる trusted binding を追加した。
  • artifact 一覧取得の pagination を追加(total_count に基づき page 2 以降を走査)し、run_attempt の型不正(null / 文字列 / 0 / 負値)と (workflow_run_id, job, run_attempt) 衝突を fail-closed で検出する回帰テストを新設した。

Checks

以下の検証コマンドを実行し、いずれも成功したことを確認した。

  • uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/ — 49 件成功
  • uv run --locked pytest tests/ci/test_ci_performance_gate.py tests/ci/test_ci_performance_gate_rerun_attempt_selection.py — 40 件成功、3 件 SKIP(実 GitHub API / 実 20-run cohort 依存分は環境上 SKIP、fabricated PASS ではない)
  • uv run --locked pytest tests/ci/ フルディレクトリ — 44 件成功、7 件 SKIP(既存 satellite テストに退行なし)
  • 変更ファイルに対する uv run ruff check — 全チェック成功
  • pnpm typecheck — 成功
  • pnpm lint — 成功
  • pnpm test — 112 ファイル・1872 件のテストが成功
  • pnpm build — 成功
  • uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py — 24 件成功
  • Issue 実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする #2179 記載の AC1〜AC10 の個別 Verification Commands(::test_name 単位)をすべて実行し、PASS を確認済み
  • fix_delta iteration 2(_normalize_run_attempt の docstring 是正・PR body 更新・follow-up Issue 実装: e2e performance gate 側の _normalize_run_attempt を missing run_attempt 除外ポリシーに統一する #2187 明記のみ、ロジック変更なし)でも同一検証コマンドを再実行し、全件成功を確認済み(pnpm test は 112 ファイル・1872 件成功。並列環境下で tests/retro-live-verification.test.ts の一部がタイムアウトする既知の flaky が発生することがあるが、本 PR の変更ファイル対象外かつ単体実行で 148/148 PASS を確認済み)

Schema Change Applicability

- decision: schema_change

schemas/e2e_performance_benchmark_manifest_v1.schema.json の RunRecord(unevaluatedProperties: false)に、後方互換な OPTIONAL field として run_attempt(integer >= 1)と rerun_attempt_selection_policy(string)を追加した。既存の必須フィールド(required 配列)は変更していない。

Schema Consumer Inventory

before

{
  "RunRecord": {
    "required": ["workflow_run_id", "job", "head_sha", "artifact_id", "artifact_digest", "conclusion", "workflow_digest", "workflow_sha"],
    "unevaluatedProperties": false,
    "properties": {
      "workflow_run_id": "integer >= 1",
      "...": "既存フィールドのみ"
    }
  }
}

after

{
  "RunRecord": {
    "required": ["workflow_run_id", "job", "head_sha", "artifact_id", "artifact_digest", "conclusion", "workflow_digest", "workflow_sha"],
    "unevaluatedProperties": false,
    "properties": {
      "workflow_run_id": "integer >= 1",
      "...": "既存フィールド",
      "run_attempt": "integer >= 1 (optional, 後方互換)",
      "rerun_attempt_selection_policy": "string (optional, 後方互換)"
    }
  }
}
Consumer ファイル 更新有無 備考
scripts/ci/collect_e2e_performance_benchmark.py 更新済み _collect_arm が全 RunRecord に run_attempt / rerun_attempt_selection_policy を出力するよう変更(本 PR)。
tests/ci/test_ci_performance_gate.py 更新済み _cli_run_details_from_pairs が run_attempt: 1 ハードコードから実際の選択結果を伝播する実装へ変更(本 PR)。
.claude/skills/ci-test-performance/scripts/validate_ci_performance_assessment_v2.py 未変更(影響なし) CI_TEST_PERFORMANCE_ASSESSMENT_V2 は e2e_performance_benchmark_manifest_v1 を直接消費しない別スキーマであり、追加フィールドの影響を受けない。
schemas/ci_test_reliability_assessment_v1.schema.json(#2170) 未変更(対象外) 別スキーマであり、Issue #2179 の Out of Scope として明示的に除外。

Safety Claim Matrix

N/A(reason: 変更対象は scripts/ci/・tests/ci/・schemas/・docs/dev/ のみで、SAFETY_SENSITIVE_PATH_PATTERNS(transport / permission / sandbox / auth / mcp / .claude/skills/ / .github/workflows/)のいずれにも該当しない。CI performance gate のロジック変更であり、実行権限・sandbox・secret 境界には影響しない)

Known Limitations / Follow-up Issues(既知の制限事項・follow-up Issue)

Notes

collector (`scripts/ci/collect_e2e_performance_benchmark.py`) と production
performance gate (`tests/ci/test_ci_performance_gate.py`) の両方の
`_dedupe_by_workflow_run_id` / `_pair_by_workflow_run_id` を、
`dict.setdefault()` の first-seen-wins および dict 内包表記の実質
last-seen-wins(いずれも入力配列の並び順に依存)から、単一の明示的な
`initial_attempt_only_v1` ポリシー(run_attempt == 1 の成功レコードのみを
候補とし、attempt 1 が失敗/欠落しているサンプルは後続 attempt へ
フォールバックせず除外する)へ置き換える。選択した run_attempt と
ポリシー識別子を manifest の RunRecord(後方互換 optional field)に記録し、
run_attempt を live attempt-specific jobs API と突き合わせて trusted
binding する。artifact 一覧取得を全ページ走査するよう pagination を追加し、
run_attempt の型不正・0/負値・(workflow_run_id, job, run_attempt) 衝突を
fail-closed で検出する回帰テストを新設した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2182/

The preview will be removed when this PR is closed.

@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop Step 4 PR Review Verdict

Mergeability: mergeable=MERGEABLE, merge_state_status=CLEAN, isDraft=true

Evidence Check:

  • 全 required CI checks (lint, test, build, typecheck, validate-generated-artifact) が reviewed head c51a190cec723a93545f77b7d85f0d8f5092efc6 で SUCCESS。
  • allowed_paths_review_gate.py で 6 変更ファイル全て Issue 実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする #2179 の Allowed Paths(Scope Delta 反映済み)内であることを確認(status: ok, 0 violations)。
  • reviewer が独立に scratch worktree で PR head をチェックアウトし、AC1-AC10 の Verification Commands を再実行して確認(自己申告に依存しない): rerun-attempt selection 系 21 tests pass、AC10 baseline 34 pass/3 skip(既存の環境依存 skip)、AC6 rg match 確認。
  • _dedupe_by_workflow_run_id(collector/gate 両方)が initial_attempt_only_v1 ポリシーを実装し、attempt-1-only候補化・fail-closed除外・canonical sort(AC7)・pagination(AC8)・live API trusted binding(AC5, fail-closed conflict test含む)を確認。
  • schema変更は RunRecord への後方互換 optional field 追加のみ(required 不変)。Schema Consumer Inventory 記載あり。
  • Safety Claim Matrix: N/A(.claude/skills/** / .github/workflows/** 等の safety-relevant path 変更なし)。妥当。
  • スコープクリープなし。Issue の In Scope / Scope Delta と一致。

Blockers: なし

Non-blockers (Warnings):

  • PR body に ## 受け入れ条件の達成状況 の per-AC [x] checklist セクションがなく、集約的な prose 確認のみ。reviewer が独立に AC1-AC10 VC を再実行して pass を確認済みのため hygiene issue のみで merge blocker ではない。
verdict: APPROVE
reviewed_head_sha: "c51a190cec723a93545f77b7d85f0d8f5092efc6"
blockers: []
warnings:
  - "PR body lacks literal '## 受け入れ条件の達成状況' per-AC checklist section (aggregate prose confirmation used instead); independently reverified all AC1-AC10 VCs pass so this is hygiene-only, not a merge blocker."

@squne121 squne121 self-assigned this Aug 15, 2026
@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop Step 4 PR Review Verdict (stale-head re-review)

Reviewed head SHA: 9aa6d2cf034bc475b9411475e25fccd20ba13f4d(前回承認 head c51a190c... から main 統合マージコミットのみ。PR対象6ファイルの内容変更なし、compare APIで独立確認済み)

Mergeability: mergeable=MERGEABLE, merge_state_status=BLOCKED, isDraft=true

Evidence Check:

  • 全 required CI checks (lint, test, build, typecheck, validate-generated-artifact) が新 head で SUCCESS。
  • allowed_paths_review_gate.py: status ok, 0 violations(6ファイル全て Allowed Paths内)。
  • gh api compare c51a190c...9aa6d2cf で prior-approved headから現headまでの差分は .claude/skills/issue-contract-review/** 等の無関係コミットのみで、PR対象ファイルは変更なしを確認。

Blockers: なし

Non-blockers (Warnings):

  • allowed_paths_gate advisory: contract_source_kind/source_id_missing (non-blocking)
  • allowed_paths_gate advisory: expected_contract_fingerprint_missing (non-blocking)
verdict: APPROVE
reviewed_head_sha: "9aa6d2cf034bc475b9411475e25fccd20ba13f4d"
blockers: []
warnings:
  - "allowed_paths_gate advisory: contract_source_kind/source_id_missing (non-blocking)"
  - "allowed_paths_gate advisory: expected_contract_fingerprint_missing (non-blocking)"

@squne121

Copy link
Copy Markdown
Owner Author

敵対的レビュー結果

verdict: REQUEST_CHANGES
reviewed_head_sha: 9aa6d2cf034bc475b9411475e25fccd20ba13f4d
merge_ready: false
blocking_findings:
  P0: 4
  P1: 1

最終確認時点で、PR #2182 は上記 head SHA の Draft PR です。PR本文では AC1〜AC10 と各テストの成功が申告され、PRコメント上でも APPROVE が出ており、現行CIも成功しています。

ただし、テストが実GitHub APIのページング意味論を再現しておらず、追加された run_attempt の trusted binding も attempt・job・artifactを一意に結び付けていません。また、関連workflowの固定SHA計測経路と head_sha の意味が矛盾しています。現状では証跡の決定性は改善していても、証跡の真正性は保証できません。


P0-1: artifact pagination が実API上でページを飛ばす

現実装は、artifact一覧の最初のリクエストだけ query parameter なしで取得し、その後のページを per_page=100&page=2 から取得します。

GitHub Actions Artifacts API は、per_page を指定しない場合の既定値が30です。したがって、ページサイズを途中で30から100へ変更すると、ページ番号のオフセットが変わります。([GitHub Docs]1)

たとえば total_count = 31 の場合:

  1. 最初のリクエスト: 既定30件なので artifact 1〜30を取得
  2. 次のリクエスト: per_page=100&page=2
  3. これは100件単位の第2ページ、すなわち artifact 101以降を要求
  4. artifact 31は一度も取得されない

total_count = 130 なら、1〜30の次に101〜130が取得され、31〜100が丸ごと欠落します。現在の実CI runにもすでに29個のartifactがあり、境界は仮想的なものではありません。

既存テストは「1ページ目に少数件、2ページ目に残り」というスタブを返すため、GitHub APIのページ番号とページサイズの関係を再現していません。

必須修正

最初から最後まで同じページサイズを使ってください。

GET .../artifacts?per_page=100&page=1
GET .../artifacts?per_page=100&page=2
...

さらに以下を fail-closed にする必要があります。

  • len(collected) < total_count のまま空ページへ到達
  • ページ間で同一artifact IDが重複
  • 取得中に total_count が不整合に変化
  • 100件境界の off-by-one

最低限、総数130件について target artifact を位置30、31、50、100、101、130へ置くパラメタライズドテストが必要です。


P0-2: run_attempt の live binding が「そのattemptに何らかのjobが存在する」ことしか確認していない

verify_run_record_against_live_api() は attempt-specific jobs APIを呼びますが、その後に検索している条件は概ね次のものです。

job.get("run_attempt") == claimed_run_attempt

つまり以下を確認していません。

  • job.name == record["job"]
  • job.head_sha が期待するGitHub workflow runのSHAと一致
  • job.conclusion が収集対象の成功状態と一致
  • 対象artifact名が ci-runtime-baseline-{job}-{run_attempt} と一致
  • 対象artifactを生成したjobとattempt-specific jobが同一

実際の attempt-specific jobs API 応答には、run_attempt だけでなく、name、head_sha、conclusion、run_id が含まれています。現行PRの実runでもこれらのフィールドを確認できます。 GitHubのAPI仕様上も、このendpointはattemptを指定したjob一覧を返すものです。([GitHub Docs]2)

artifact側にも名前、ID、digest、workflow run情報があります。現行runの ci-runtime-baseline-e2e-core-1 にもこれらが存在します。

すり抜け例

次の入力を作ると、現実装では誤って受理され得ます。

  1. attempt 2 の正規artifact IDとdigestを取得
  2. 入力recordの run_attempt だけ1へ改変
  3. artifact ID、digest、workflow runは実在するため前半検証を通過
  4. attempt 1には別のjobが存在するため matching_jobs が空にならない
  5. attempt 2のartifactがattempt 1の証跡として扱われる

特定jobだけをrerunした場合、attempt-specific jobs集合は全job集合ではないため、この問題は単なる理論上の改ざんケースではありません。

必須修正

live bindingを少なくとも次のタプルへ強化してください。

(
  workflow_run_id,
  run_attempt,
  job_name,
  workflow_run_head_sha,
  job_conclusion,
  artifact_id,
  artifact_name,
  artifact_digest
)

artifact名は以下と完全一致させるべきです。

ci-runtime-baseline-{record.job}-{record.run_attempt}

追加すべきnegative fixturesは以下です。

  • attempt 2のartifactをattempt 1として申告
  • attempt 1には無関係なjobだけが存在
  • artifact名だけ別job
  • artifact ID/digestは正しいがrecordのjob名が不一致
  • jobの head_sha が不一致
  • jobが30件を超える場合のjobs API pagination
  • conclusion != success

可能なら、immutableなartifact ZIPをダウンロードし、内部payloadの run_id、run_attempt、job、head_sha もAPIメタデータと相互検証すべきです。


P0-3: run_attempt 欠落をattempt 1として扱うため、trusted verificationを完全に迂回できる

Issue #2179 は次の2つを別々に要求しています。

  • schema上は既存manifestを読めるよう、追加fieldをoptionalにする
  • trusted verification経路では run_attempt のmissingをfail-closedにする

特にAC9は、missing、文字列、0、負値、identity collisionをfail-closedで検出することを求めています。

しかし実装では、key自体がない場合を後方互換として run_attempt = 1 に正規化しています。さらにlive API照合は run_attempt fieldが存在するときだけ実行されます。 PR本文とドキュメントも、この欠落値のattempt 1扱いを明示しています。

結果として旧recordは:

  1. attempt-specific API bindingを受けない
  2. attempt 1として選択される
  3. 出力manifestには新たに run_attempt: 1 とポリシー名が付与される
  4. 未検証のlegacy evidenceが、検証済みattempt 1 evidenceに見える

これは後方互換ではなく、provenance laundering です。

必須修正

schema parse compatibilityとtrusted cohort eligibilityを分離してください。

run_attempt absent:
  schema_parse: allowed
  trusted_cohort: rejected/excluded
  reason: legacy_unverified_run_attempt

旧recordへ run_attempt: 1 や rerun_attempt_selection_policy を合成してはいけません。

collectorとgateの双方に次のテストが必要です。

  • missing run_attempt はtrusted cohortから除外
  • evidence_errors に専用reasonを記録
  • legacy inputを再出力しても、verifiedなattempt 1へ昇格しない
  • optional schema validationの成功とtrusted verification失敗が同時に成立する

P0-4: 固定SHA benchmark workflowの head_sha が、実際にcheckoutした計測対象SHAを表していない

関連する .github/workflows/ci.yml は、固定SHA benchmarkについて次の構造を採用しています。

  • workflow自体はcurrent/default branchをdispatch
  • target_sha を別inputとして受ける
  • actions/checkout では target_sha をcheckout
  • git rev-parse HEAD == target_sha を検証
  • workflow_sha と計測対象の head_sha を分離する、とコメントで規定

一方、artifact producerの GH_HEAD_SHA は次の値です。

GH_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}

そしてこれをartifactの head_sha に書き込んでいます。

workflow_dispatch における GITHUB_SHA は、dispatchされた GITHUB_REF の最新commitです。checkout後の任意の target_sha へ自動的に変わる値ではありません。([GitHub Docs]3)

したがって、たとえば:

main tip:       BBBBBBB...
target_sha:     AAAAAAA...
checkout HEAD:  AAAAAAA...
GH_HEAD_SHA:    BBBBBBB...
artifact.head_sha: BBBBBBB...

となります。

新しいlive verifierが artifact.head_sha を計測対象commitとして扱えば、正規の固定SHAサンプルを拒否します。一方、GitHub workflow runの head_sha として扱えば、計測対象commitとのbindingが失われます。現在の単一fieldでは両方を表現できません。

これはPRの変更対象外に見えますが、PRが追加したtrusted verificationの実運用producerそのものです。Issue #2159のbenchmark設計も、workflow definitionと計測対象commitを分離する前提です。

必須修正

以下を別fieldとして扱ってください。

measured_head_sha        = verified `git rev-parse HEAD`
workflow_run_head_sha    = GitHub API workflow run head_sha
workflow_sha             = github.workflow_sha

既存の head_sha を維持するなら、意味は measured_head_sha に固定し、producerでは検証済みのcheckout HEADまたは検証済み target_sha を書き込むべきです。

この修正は:

  • PR #2182にscopeを追加して行う
  • または prerequisite PRとして先にmergeする

のどちらかが必要です。現状のまま #2179 を Closes するのは不適切です。

検証には、main tipとtarget_shaが異なる実 workflow_dispatch が必要です。ユニットテストだけでは成立しません。


P1・blocking: 同一identityの内容衝突をcanonical sortで隠している

collectorとgateは、同じworkflow runに複数のattempt 1候補がある場合、JSONのcanonical表現で min() を選びます。これにより入力順依存はなくなりますが、矛盾したrecordの一方を黙って選ぶ挙動になります。

現在のcollision検出は主としてartifact IDまたはdigestの相違を対象にしています。このため、同じartifact ID/digestのまま以下が異なるrecordはcanonical minimumへ縮退し得ます。

  • head_sha
  • conclusion
  • workflow_digest
  • workflow_sha
  • measurement値
  • environment fingerprint
  • policy identifier

決定論的にどちらかを選べることと、どちらが真正であるかは別問題です。

必須修正

identityを次に固定します。

(workflow_run_id, job, run_attempt)

同一identityの重複は:

  • normalized full recordが完全一致する場合のみidempotent duplicateとして許可
  • 1 fieldでも異なればworkflow run全体をfail-closedで除外

としてください。

collectorとgateで別実装を持たず、正規化・identity検証・選択ポリシーを共有moduleへ抽出するのが妥当です。

必要なテストは:

  • 同一ID/digestで head_sha だけ異なる
  • conclusion だけ異なる
  • measurementだけ異なる
  • fingerprintだけ異なる
  • policy名だけ異なる
  • 完全同一duplicateは結果不変
  • missing attempt recordと明示attempt 1 recordの混在は衝突

です。


追加改善事項

policy identifierを任意文字列にしない

ドキュメントと実装は単一ポリシー initial_attempt_only_v1 を規定していますが、schemaは単なるnon-empty stringとして受理します。

少なくとも次のいずれかへ変更すべきです。

{ "const": "initial_attempt_only_v1" }

または将来拡張を見込むなら:

{ "enum": ["initial_attempt_only_v1"] }

不明なポリシー名を知っているポリシーとして処理してはいけません。

Runtime Verification Applicability の判定が不正確

PR本文はこの変更を「純粋な静的変更」として not_applicable にしています。

しかし変更内容には:

  • GitHub API pagination
  • attempt-specific endpoint
  • artifact metadata
  • rerun時のjob集合
  • workflow_dispatchのSHA semantics

が含まれます。すべて外部runtime契約です。現在の実runはartifact 29件・attempt 1のみであり、今回の主要境界を通っていません。したがって、少なくとも required または applicable_with_live_api_smoke とすべきです。

rerunを除外したperformance結果とreliabilityを混同しない

initial_attempt_only_v1 はrerun成功だけを選ぶcherry-pickingを防ぐ点では妥当です。一方、attempt 1失敗runをperformance cohortから除外するため、performance分布だけを見ると失敗率が消えます。reliability/failure rateは別Issue #2170の評価対象として独立に保持する必要があります。


評価できる点

以下は方向として正しいです。

  • workflow_run_id を独立サンプル単位とする
  • rerun成功へのフォールバックを禁止する
  • success filteringより前にattempt 1を選ぶ
  • 出力配列を固定キーでcanonical sortする
  • collectorとgateの旧first-seen/last-seen差異を解消しようとしている
  • run_attempt とポリシー名をmanifestに記録する

これらはPR #2172で指摘された、rerunによる水増しと入力順依存への有効な修正です。

問題は、その上に追加したtrusted evidence層がまだtrustedになっていないことです。


マージ条件

以下をすべて満たすまで REQUEST_CHANGES を維持すべきです。

  1. artifact paginationで全ページに同一 per_page を使い、30/31/100/101境界のテストを追加する。
  2. live bindingをexact job・attempt・head SHA・conclusion・artifact name・ID・digestへ拡張する。
  3. missing run_attempt をtrusted cohortではfail-closedにし、attempt 1へ昇格させない。
  4. 固定SHA workflowでmeasured SHAとworkflow-run SHAを別fieldへ分離する。
  5. 同一identityの非同一duplicateをcanonical選択せず、衝突として除外する。
  6. rerun_attempt_selection_policy をschema上で既知値に限定する。
  7. main tipとtarget SHAが異なる実 workflow_dispatch と、特定job rerunを使ったlive negative verificationを提示する。
  8. 下記の回帰テストと通常CIを全件成功させる。
uv run --locked pytest \
  scripts/ci/tests/e2e_performance_benchmark/ \
  tests/ci/test_ci_performance_gate.py \
  tests/ci/test_ci_performance_gate_rerun_attempt_selection.py \
  -q

uv run --locked ruff check \
  scripts/ci/collect_e2e_performance_benchmark.py \
  scripts/ci/tests/e2e_performance_benchmark/ \
  tests/ci/test_ci_performance_gate.py \
  tests/ci/test_ci_performance_gate_rerun_attempt_selection.py

pnpm typecheck
pnpm lint
pnpm test
pnpm build

最重要なのは、「順序に依存せず同じrecordを選ぶ」だけでなく、「選ばれたrecordがGitHub上のそのrun・そのattempt・そのjob・そのartifactから生成されたことを一意に証明する」ことです。現headは前者を概ね満たしていますが、後者は未達です。

…り fail-closed 化する (fix_delta iteration 1)

Issue #2179 / PR #2182 の OWNER adversarial review REQUEST_CHANGES
(issuecomment-5302446086, reviewed_head_sha 9aa6d2c) を反映した fix_delta。

- P0-1: artifact pagination の page size を 1 ページ目から一貫して
  per_page=100 にし、total_count 未達での空ページ・重複 artifact ID・
  total_count 途中変化を fail-closed で検出する。
- P0-2: live-binding の trusted identity タプルを
  (workflow_run_id, run_attempt, job_name, workflow_run_head_sha,
  job_conclusion, artifact_id, artifact_name, artifact_digest) に拡張し、
  attempt 2 の artifact を attempt 1 と偽る relabeling を拒否する。
- P0-3: run_attempt が完全に欠落したレコードを collector 側で trusted
  cohort から除外し(legacy_unverified_run_attempt)、run_attempt: 1 を
  合成しない。gate 側は Allowed Paths 外の satellite テストへの影響を
  避けるため、この項目は意図的に対象外とし docs に明記した。
- P1: identity 衝突検出を (workflow_run_id, job, run_attempt) の
  全フィールド byte-for-byte 比較に変更し、min() による黙った解決を廃止
  (collector・gate 双方に適用)。
- schema hygiene: rerun_attempt_selection_policy を enum 制約に絞る。

P0-4(.github/workflows/ci.yml の head_sha 意味論)は #2179 の Allowed
Paths 外のため対象外とし、follow-up Issue #2184 に分離した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

fix_delta iteration 1: OWNER adversarial review 対応(reviewed_head_sha 9aa6d2cf)

対象コメント: #2182 (comment)

新しい head: a9cbc201e94517723ddc55ef552f1e5bdefd5729(同一ブランチ worktree-issue-2179-rerun-attempt-selection へ push、新規 PR は作成していない)

対応した Blocker

  • P0-1(artifact pagination の page size 不整合): 1 ページ目のリクエストで per_page を省略していたため(GitHub のデフォルト 30)、2 ページ目以降の per_page=100 と食い違い、total_count が 31 以上の run で artifact 31〜100 が黙ってスキップされ得た。1 ページ目から一貫して per_page=100 を使用するよう修正し、加えて (a) total_count 未達での空ページ到達、(b) ページ間での artifact ID 重複、(c) フェッチ途中での total_count 変化、を LiveAPIError(fail-closed)として検出するようにした。total_count=130 で対象 artifact を位置 30/31/50/100/101/130 に置くパラメタライズド回帰テストを追加。
  • P0-2(live-binding の識別子が弱い): verify_run_record_against_live_api の trusted identity タプルを (workflow_run_id, run_attempt, job_name, workflow_run_head_sha, job_conclusion, artifact_id, artifact_name, artifact_digest) に拡張。attempt-specific jobs API のレスポンスに対応する job の name/head_sha/conclusion の一致を要求し、artifact 自身の name も ci-runtime-baseline-{job}-{run_attempt}(.github/workflows/ci.yml の命名規約と一致)を要求するようにした。attempt-2 の artifact を attempt-1 と偽る relabeling、job 名不一致、job head_sha 不一致、conclusion != success、jobs API に 30+ job が含まれる場合、の回帰テストを追加。
  • P0-3(run_attempt 欠落レコードの trusted attempt-1 への暗黙昇格): collector 側(scripts/ci/collect_e2e_performance_benchmark.py)で run_attempt が完全に欠落しているレコードを trusted/selected cohort から除外するよう修正した(_classify_run_attempt が "missing" と "invalid" を区別し、両方とも selection から除外。除外理由は前者が legacy_unverified_run_attempt、後者が既存の missing_or_invalid_initial_attempt_excluded_from_sample)。manifest 出力に run_attempt: 1 / rerun_attempt_selection_policy が合成されることはなくなった。schema 構造検証自体は除外レコードでも独立して成功することを確認する回帰テストも追加。
    • スコープ境界(要 reviewer 確認): gate 側(tests/ci/test_ci_performance_gate.py::_normalize_run_attempt)はこの是正を意図的に適用していない。gate 側で同じ厳格化を行うと tests/ci/test_ci_performance_gate_paired_critical_path.py 等、Issue 実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする #2179 の Allowed Paths 外にある satellite テストの固定 fixture(run_attempt を一切設定していない)が壊れ、Stop Condition(Allowed Paths 外ファイルへの変更が必須と判明した場合)に抵触するため。この非対称性は docs/dev/e2e-performance-benchmark.md に明記した。follow-up Issue でこれらの satellite ファイルを Allowed Paths に含めた上で統一することを推奨する。
  • P1(identity 衝突が min() で黙って解決される): identity 衝突検出を (workflow_run_id, job, run_attempt) の全フィールド byte-for-byte 比較に変更(従来は artifact_id/artifact_digest のみ比較)。head_sha・conclusion・workflow_digest・workflow_sha・測定値・comparability fingerprint・選択ポリシー名のいずれかが異なれば、その workflow_run_id サンプル全体を fail-closed で除外するようにした。collector・gate 双方に同一パターンで適用(gate 側はこの collision fix については collector と完全に整合)。byte-identical 重複は無害な重複として維持されることも回帰テストで確認。
  • hygiene(非 blocking): schemas/e2e_performance_benchmark_manifest_v1.schema.json の rerun_attempt_selection_policy を任意の非空文字列から enum: ["initial_attempt_only_v1"] に絞った。

明示的にスコープ外(P0-4 は follow-up へ分離)

検証結果(すべて PASS、head a9cbc201)

uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/ tests/ci/test_ci_performance_gate.py tests/ci/test_ci_performance_gate_rerun_attempt_selection.py -q
  -> 83 passed, 3 skipped(skip は live gh CLI / 実 20-run cohort 依存分。fabricated PASS ではない)

uv run --locked ruff check scripts/ci/collect_e2e_performance_benchmark.py scripts/ci/tests/e2e_performance_benchmark/ tests/ci/test_ci_performance_gate.py tests/ci/test_ci_performance_gate_rerun_attempt_selection.py
  -> All checks passed

uv run --locked pytest tests/ci/ -q  -> 52 passed, 4 skipped(satellite 含む全 gate テスト、退行なし)
uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark.py -q -> 34 passed(既存 baseline、退行なし)

pnpm typecheck -> pass
pnpm lint -> pass
pnpm test -> 1872 件中 1870〜1872 pass。`tests/retro-live-verification.test.ts` の一部テストが並列実行下でタイムアウトする既知の flaky(本 PR の変更ファイル対象外。単体実行では 148/148 PASS を確認済み)
pnpm build -> pass
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -> 24 passed

Allowed Paths 準拠

変更ファイルは Issue #2179 の Allowed Paths 6 パスの範囲内のみ(.github/workflows/** は不変):

  • scripts/ci/collect_e2e_performance_benchmark.py
  • scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark.py
  • scripts/ci/tests/e2e_performance_benchmark/test_collect_e2e_performance_benchmark_rerun_attempt.py
  • tests/ci/test_ci_performance_gate.py
  • tests/ci/test_ci_performance_gate_rerun_attempt_selection.py
  • schemas/e2e_performance_benchmark_manifest_v1.schema.json
  • docs/dev/e2e-performance-benchmark.md

@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop Step 4 PR Review Verdict (fix_delta iteration 1 re-review)

Reviewed head SHA: a9cbc201e94517723ddc55ef552f1e5bdefd5729

Evidence Check:

  • P0-1(artifact pagination): FIXED(per_page=100統一・fail-closed実装・パラメタライズドテスト確認)
  • P0-2(live binding弱さ): FIXED(8要素タプルへ拡張、relabel攻撃阻止テスト確認)
  • P0-4(ci.yml head_sha意味論): 適切にAllowed Paths外として follow-up Issue 実装: 固定SHA benchmark artifact の head_sha 意味論混同を measured_head_sha/workflow_run_head_sha 分離で修正する #2184 へ分離済み、.github/workflows/** 変更なし確認
  • P1(identity collision): FIXED(collector/gate両方でbyte-for-byte比較・fail-closed確認)
  • CI: 全required checks(lint/test/typecheck/build/python-test/validate-generated-artifact)SUCCESS
  • Allowed Paths: 7ファイル全て準拠

Blockers:

  • P0-3(missing run_attemptの信頼コホート昇格)が collector 側のみ修正され、gate 側(tests/ci/test_ci_performance_gate.py::_normalize_run_attempt)は依然として missing run_attempt を attempt-1 として信頼扱いする非対称性が残存。コード内正当化コメント(「事前存在baselineとの後方互換性」)はgit historyと矛盾(ci_runtime_baseline_v1 は導入時からrun_attemptを常に含む、commit 9574ee5 で確認)。真の制約(tests/ci/test_ci_performance_gate_paired_critical_path.pyのfixtureがAllowed Paths外)は事実確認済みだが、これに対する追跡先(follow-up Issueやscope decision)が存在しない。OWNERはcollector/gate双方の修正を明示的に要求しており、#2184と同様の扱い(follow-up Issue化)または明示的なOWNER容認のいずれかが必要。

Non-blockers (Warnings):

  • PR body の per-AC checklist セクション欠落(hygiene のみ、既存 VC 再検証済み)
  • gate側の_normalize_run_attemptが数値文字列型run_attemptを受理する点(collectorはint限定)は意図的仕様。
verdict: REQUEST_CHANGES
reviewed_head_sha: "a9cbc201e94517723ddc55ef552f1e5bdefd5729"
blockers:
  - "P0-3 gate-side asymmetry unresolved: tests/ci/test_ci_performance_gate.py::_normalize_run_attempt still trusts a missing run_attempt as attempt-1, unlike the collector's fixed exclusion. No follow-up Issue or explicit OWNER acknowledgment exists for this gap (unlike P0-4/#2184)."
warnings:
  - "PR body lacks literal per-AC checklist section (hygiene-only)."
  - "gate-side numeric-string run_attempt acceptance vs collector's strict int-only is intentional and non-blocking."

… iteration 2)

pr-reviewer REQUEST_CHANGES (issuecomment-5302595322) の指摘どおり、
`_normalize_run_attempt` の docstring が「run_attempt フィールド追加前の
baseline との後方互換性」という事実誤認コメントを含んでいた。
`ci_runtime_baseline_v1` は導入コミット 9574ee5 から常に run_attempt を
含んでいるため誤り。

missing run_attempt を trusted attempt-1 として扱う既知の制限は、
このゲートモジュール自身の Allowed Paths 境界(satellite fixture files
である tests/ci/test_ci_performance_gate_paired_critical_path.py 等が
scope 外)によるものであり、その完全統一のための追跡先として follow-up
Issue #2187 を明記した。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121

Copy link
Copy Markdown
Owner Author

fix_delta iteration 2: pr-reviewer REQUEST_CHANGES 対応(reviewed_head_sha a9cbc201)

対象コメント: #2182 (comment)

新しい head: 0de7dc54(同一ブランチ worktree-issue-2179-rerun-attempt-selection へ push、新規 PR は作成していない)

対応した Blocker

検証結果(すべて PASS、head 0de7dc54)

uv run --locked pytest scripts/ci/tests/e2e_performance_benchmark/ tests/ci/test_ci_performance_gate.py tests/ci/test_ci_performance_gate_rerun_attempt_selection.py -q
  -> 83 passed, 3 skipped

uv run --locked ruff check scripts/ci/collect_e2e_performance_benchmark.py scripts/ci/tests/e2e_performance_benchmark/ tests/ci/test_ci_performance_gate.py tests/ci/test_ci_performance_gate_rerun_attempt_selection.py
  -> All checks passed

pnpm typecheck -> pass
pnpm lint -> pass
pnpm test -> 112 ファイル・1872 件成功
pnpm build -> pass
uv run --locked pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -> 24 passed

変更範囲

  • tests/ci/test_ci_performance_gate.py(docstring のみ、ロジック変更なし)
  • PR body(Known Limitations / Follow-up Issues 節を追加)

.github/workflows/** および satellite fixture ファイル(tests/ci/test_ci_performance_gate_paired_critical_path.py 等)には一切触れていない。

@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop Step 4 PR Review Verdict (fix_delta iteration 2 re-review)

Reviewed head SHA: 0de7dc54b67d10414e1d407af80882c188fc6e9a

Evidence Check:

Blockers: なし

verdict: APPROVE
reviewed_head_sha: "0de7dc54b67d10414e1d407af80882c188fc6e9a"
blockers: []
warnings: []

@squne121
squne121 marked this pull request as ready for review August 15, 2026 15:06
@squne121
squne121 merged commit 1433ab8 into main Aug 15, 2026
54 of 62 checks passed
@squne121
squne121 deleted the worktree-issue-2179-rerun-attempt-selection branch August 15, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: e2e performance benchmark の rerun attempt 選択を順序非依存の決定論的ポリシーにする

1 participant