Skip to content

fix: performance close-grade materializer をtopology-aware実装に修正しmonolith armのeligible run生成を可能にする - #2575

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-2554-performance-close-grade-materializer-top
Sep 8, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-2554-performance-close-grade-materializer-top

Conversation

@squne121

@squne121 squne121 commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

Issue #2554 の実装です。tests/ci/test_ci_performance_gate.py の production Performance close-grade materialization path(run_evidence_gate() → _pair_by_workflow_run_id() → provider post-filter sample count → percentile/assessment input → build_close_grade_receipt() → _materialize_close_grade_arm())が manifest topology(monolith / split)を無視しており、monolith arm が構造的に performance_eligible_workflow_run_ids == [] になる gap を修正しました。この gap は #2155 の44-run本番experiment実行のhard prerequisiteとして OWNER anchor comment(issuecomment-5568218806)で指摘されたものです。

  • 新設した共通 helper _layout_aware_provider_baselines(topology, core_baselines, responsive_baselines) を tests/ci/test_ci_performance_gate.py に追加しました。呼び出し側が渡す明示的な topology 引数("monolith" / "split" -- baseline の内容から自動推定はしない)に応じて、_pair_by_workflow_run_id() / _provider_post_filter_sample_count() / _materialize_close_grade_arm() へ渡す (core_baselines, responsive_baselines) ペアを組み立てます。
  • monolith: 物理 provider は e2e-core 1個のみ。同一の e2e-core baseline を core レーン・responsive レーン双方へ渡すことで(self-fingerprint-matching)、_pair_by_workflow_run_id() はその run を自分自身とペアリングします。_provider_critical_path_paired_p50_p95() の max(core, responsive) は同一 baseline の値へ collapse するため、test_e2e_ci + test_e2e_monolith_responsive の合計を一度だけ観測値として使い、二重計上しません。synthetic な e2e-responsive-matrix レコードは一切生成しません。
  • split: _layout_aware_provider_baselines() は (core_baselines, responsive_baselines) をそのまま返し、既存の max(core, responsive) critical-path semantics は無変更です。responsive provider が本当に欠落する split run は引き続き missing_pair_e2e-responsive-matrix の fail-closed error になります。
  • run_evidence_gate()(pairing / sample count / assessment input)と build_close_grade_receipt()(_materialize_close_grade_arm() 呼び出し)の両方をこの共通 helper へ収束させ、既存の arms.monolith <- fixture["before"] / arms.split <- fixture["after"] stand-in convention をそのまま topology tag として使っています。_pair_by_workflow_run_id() / _provider_critical_path_paired_p50_p95() / _materialize_close_grade_arm() 自体のシグネチャ・不変条件は変更していません。

Checks

  • uv run --locked pytest tests/ci/test_ci_performance_gate.py -q(22 passed, 3 skipped -- skip は既存の実CI history依存exploratory testで無関係)
  • uv run --locked pytest tests/ci/ -q(全 satellite test file を含む -- 113 passed, 5 skipped)
  • pnpm typecheck
  • pnpm lint
  • pnpm test(Vitest 1939 件 PASS)
  • pnpm build
  • uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(24 件 PASS)
  • uv run ruff check tests/ci/test_ci_performance_gate.py(エラーなし)

受け入れ条件の達成状況

  • AC1: test_monolith_provider_post_filter_sample_count_equals_run_count_with_no_responsive_provider -- monolith 20-run fixture(各 run が単一の e2e-core baseline のみを持ち、measurements[] に test_e2e_ci + test_e2e_monolith_responsive を含み、responsive_baselines=[])で provider post-filter sample count が 20 であることを確認。
  • AC2: test_monolith_arm_close_grade_receipt_eligible_ids_has_20_entries_via_before_stand_in -- AC1 と同じ fixture を fixture["before"] に配置し、build_close_grade_receipt() の arms.monolith.performance_eligible_workflow_run_ids が 20 件であることを確認。
  • AC3: test_monolith_run_duration_equals_sum_of_core_and_monolith_responsive_phases_no_synthetic_record -- 1 run の Performance duration observation が同一 e2e-core baseline の対象2 phase の合計と一致し、job == "e2e-responsive-matrix" の synthetic record が生成されないことを確認(monolith_responsive is monolith_core かつ self-pair であることも直接アサート)。
  • AC4: test_split_arm_preserves_max_core_responsive_critical_path_semantics_via_after_stand_in -- split 20-run fixture(e2e-core + e2e-responsive-matrix)を fixture["after"] に配置し、max(core, responsive) critical-path semantics(duration・provider count・receipt eligibility)が既存通り成立することを確認。
  • AC5: test_split_arm_genuinely_missing_responsive_provider_still_fails_closed(negative regression)-- split fixture で responsive provider が本当に欠落する run について、既存の missing_pair_e2e-responsive-matrix fail-closed error が引き続き発生することを確認。
  • AC6: test_production_assessment_input_uses_same_layout_aware_observation_as_close_grade_receipt -- run_evidence_gate() の production assessment input(percentile 計算・run-details)が monolith/split 両 fixture で同一の layout-aware materialized observation を経由し、build_close_grade_receipt() の eligible ids と収束することを確認(sample count・run-details duration・eligible ids の全てが一致)。
  • AC7: pnpm typecheck / pnpm lint / pnpm test / pnpm build が全て PASS。
  • AC8: uv run --locked pytest tests/ci/test_ci_performance_gate.py -q が PASS(22 passed, 3 skipped)。

既存テストへの影響と1件の修正について

既存の regression test は全て無修正で PASS しますが、1件のみ fixture を修正しました。test_close_grade_result_receipt_complete_sourced_from_gate_status_not_local_evidence_errors(#2423 fix_delta P0-1 の gate_status 独立性を証明するテスト)は、before arm の responsive_baselines: [] を「unpaired -> evidence_errors」として使っていましたが、本 PR の修正により monolith topology では responsive_baselines が空でも self-pairing で正しく eligible になるため(これがまさに本 Issue が修正する構造的欠陥です)、このテストの前提が崩れます。テストの本来の意図(performance_assessment.complete が gate_status のみに従い、receipt 自身の evidence_errors を再導出しないこと)を保ったまま、gate_ready_baselines: [] にして missing_gate_ready_evidence という別の genuine な evidence error を発生させるよう修正しました(topology に依存しない evidence error のため、本 PR の修正と無矛盾です)。それ以外の既存 close-grade materializer テスト(_materialize_close_grade_arm() を直接呼ぶもの)は、本 PR がその private helper のシグネチャ・内部ロジックを一切変更していないため無影響です。また _manifest_v2_provider_jobs_to_baselines の regression test(1717行付近)と fingerprint_mismatch / fingerprint_placeholder / run_attempt_identity_collision の regression test(2207/2253/2272行付近)は Issue の Out of Scope により無変更のままです。

検証コマンド結果

$ uv run --locked pytest tests/ci/test_ci_performance_gate.py -q
.sss.....................                                                [100%]
22 passed, 3 skipped in 0.17s

$ uv run --locked pytest tests/ci/ -q
.sss...................................................................  [ 61%]
..............................s.........s.....                          [100%]
113 passed, 5 skipped in 11.62s

$ pnpm typecheck
$ tsc --noEmit
(no errors)

$ pnpm lint
ESLint: No issues found

$ pnpm test
 Test Files  108 passed (108)
      Tests  1939 passed (1939)

$ pnpm build
$ tsc && vite build
✓ built in 177ms

$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py -q
Pytest: 24 passed

$ uv run ruff check tests/ci/test_ci_performance_gate.py
[]

Allowed Paths 遵守

git diff --name-only main...HEAD で確認した変更ファイルは以下の1件であり、Issue #2554 の Allowed Paths(tests/ci/test_ci_performance_gate.py)と完全に一致します(Allowed Paths 外の変更なし):

tests/ci/test_ci_performance_gate.py

Runtime Verification Evidence(実行証跡)

本 Issue の Runtime Verification Applicability は decision: not_applicable(pytest による静的/決定論的な evidence-shape 検証のみで完結し、実CI dispatch や runtime smoke を必要としないため)。live GitHub Actions dispatch / 44-run 本番 experiment の実行は #2155 側が別途所有します。上記「検証コマンド結果」の focused pytest 実行ログが本 Issue の検証証跡です。

Schema Change Applicability

  • decision: not_schema_change
  • reason: CI_PERFORMANCE_CLOSE_GRADE_RESULT_V1(build_close_grade_receipt() の出力 schema)のフィールド名・形状は変更していません。変更対象は production の provider observation materialization ロジック(run_evidence_gate() / build_close_grade_receipt() の内部呼び出し配線)と、それを検証するテストのみです。_pair_by_workflow_run_id() / _provider_critical_path_paired_p50_p95() / _materialize_close_grade_arm() の private helper シグネチャも無変更です。

Schema Consumer Inventory

N/A
reason: schema_change ではないため該当なし。

Safety Claim Matrix

N/A
reason: 変更対象は tests/ci/test_ci_performance_gate.py 内のテストロジック(production の provider observation materialization を検証する pytest コード)のみであり、SAFETY_SENSITIVE_PATH_PATTERNS(transport / permission / sandbox / auth / mcp / .claude/skills/ / .github/workflows/)のいずれにも一致しません。

Notes

…th armのeligible run生成を可能にする (#2554)

production の Performance close-grade materialization path
(run_evidence_gate() / _pair_by_workflow_run_id() / provider
post-filter sample count / percentile・assessment input /
build_close_grade_receipt() / _materialize_close_grade_arm()) が
manifest topology (monolith / split) を無視しており、monolith arm が
構造的に performance_eligible_workflow_run_ids == [] になる gap が
#2155 の44-run本番experimentのhard blockerだった。

新設した共通helper _layout_aware_provider_baselines() が、呼び出し側
から渡される明示的な topology tag (monolith / split -- baseline内容
からの自動推定はしない) に基づき、monolith runでは同一の e2e-core
baselineをcore/responsive両レーンへ渡すことで既存の
_pair_by_workflow_run_id() / _provider_critical_path_paired_p50_p95()
/ _materialize_close_grade_arm() のシグネチャ・2-sided pair不変条件
を変更せずにself-pairingさせ、test_e2e_ci + test_e2e_monolith_
responsiveの合計を一度だけ観測値として使う。splitはmax(core,
responsive)のまま変更なし。

run_evidence_gate()とbuild_close_grade_receipt()の両方をこの共通
helperへ収束させ、sample count・percentile/assessment input・
run-details・close-grade receipt eligibilityがすべて同一の
layout-aware観測を消費するようにした。

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

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Preview URL

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

The preview will be removed when this PR is closed.

@squne121

squne121 commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

impl-review-loop verdict (iteration 0)

Mergeability: mergeable: MERGEABLE, merge_state_status: UNSTABLE(非-required job ci-verdict-summary が overall_status='gh_error' の transient API error で失敗しているためだが、required_status_checks の contexts(typecheck/lint/test/build/python-test/validate-generated-artifact)は全て SUCCESS)。isDraft=true のため merge は行わない(人間判断待ち)。

Evidence Check:

  • 独立 test-runner が head 72d1c730fce209bd8c820866971a137ee567b980 で literal Verification Commands 5件を実行し、全PASS(AC1-AC8 該当テスト関数を個別確認)。
  • Allowed Paths gate: tests/ci/test_ci_performance_gate.py のみ変更(他ファイル変更なし)。
  • pr-reviewer が empirical non-vacuousness 検証(本番 wiring を revert して AC2/AC6 が実際に FAIL することを確認)まで実施済み。

Blockers: []
Non-blockers / Warnings:

  • PR は Draft のまま(isDraft=true)。ユーザー指示により本 loop では merge / auto-merge を行わない。
  • ci-verdict-summary(非-required)が gh_error で fail しているが、required checks には含まれておらず、merge-ready 判定には影響しない。
verdict: APPROVE
reviewed_head_sha: "72d1c730fce209bd8c820866971a137ee567b980"
blockers: []
warnings:
  - "PR is Draft; not merging per operator instruction."
  - "Non-required check ci-verdict-summary failed with overall_status=gh_error (transient); required_status_checks all SUCCESS."

@squne121

squne121 commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

判定

REQUEST_CHANGES。P1 の merge blocker を1件だけ修正すれば、承認寄りです。

PR #2575 の中心設計――monolith では同一 e2e-core baseline を self-pair し、split では従来どおり max(core, responsive) を使う――は妥当です。元の #2554 で問題だった「adapter だけ直して production path が直らない」状態も解消され、run_evidence_gate() と build_close_grade_receipt() の双方が同じ topology-aware helper を通るようになっています。新規テストも happy path と split negative regression をかなり適切に固定しています。

ただし、monolith を eligible にする新しい成功経路が、monolith の Performance observation 自体が完全であることを確認していません。

Severity | Finding | Disposition -- | -- | -- P1 / merge blocker | monolith e2e-core に必要な2 phaseの片方が欠けても、self-pairによって有効な Performance sample / eligible run として通る | このPRで修正推奨 P2 | monolith に予期せぬ responsive_baselines が入っても捨ててしまい、topology contamination を診断しない | 非blocking。#2155 blocks=1 smokeで観測されるなら別途修正

P1 — partial monolith timing evidence が valid sample になる

refined #2554 の前提では、monolith の物理 provider は e2e-core 1個で、その同じ job 内の

test_e2e_ci
+
test_e2e_monolith_responsive

を一度だけ合計したものが1 runの Performance observation です。

実 workflow もその形になっています。通常 E2E を test_e2e_ci として計測し、monolith 時には追加 responsive workload を test_e2e_monolith_responsive として同じ e2e-core 内で計測しています。

ところが現在の _job_duration_seconds() は、存在する phase_id.startswith("test_e2e") を全部足すだけです。必要な phase の集合は検証していません。1個でも正の timing があれば duration が成立します。

さらに #2575 では monolith に対して、

(core_baselines, core_baselines)

という self-pair を作ります。_provider_critical_path_paired_p50_p95() は双方の duration が存在すれば max() を取り、その pair を sample として数えます。self-pair なら片方の不完全な baseline が両側で同時に「durationあり」になります。

したがって例えば、本来

test_e2e_ci                    = 120 sec
test_e2e_monolith_responsive   =  90 sec
correct observation            = 210 sec

である run が、何らかの evidence collection 異常で responsive phase を欠き、

test_e2e_ci = 120 sec

だけになっていても、120 sec の valid monolith sample として数えられます。

そして close-grade materializer は provider pair・fingerprint・gate-ready evidence は検査しますが、provider baseline の required phase completeness は検査しません。そのため、その run は performance_eligible_workflow_run_ids にも入り得ます。

特に問題なのは、新規 fixture generator が常に両 phase を入れているため、この反例を現在の AC1〜AC6 が一切踏んでいない点です。

最小修正

大きな abstraction や schema は不要です。この PR の思想のまま局所修正できます。

  • monolith observation を eligible/countable にする前に、同一 e2e-core.measurements[] に test_e2e_ci と test_e2e_monolith_responsive が両方あり、利用可能な duration を持つことを確認する。

  • 欠落した run は silent drop せず、missing_monolith_performance_phase のような明示的 evidence error に落とし、provider post-filter count と receipt eligibility の双方から除外する。

  • regression として「20件中1件から responsive phase を除去 → provider sample count 19、その run は receipt eligible ではなく evidence_errors に入る」を1本追加する。対称的に core phase 欠落も1ケースあれば十分です。

これなら #2575 が狙っている sample-count / assessment / receipt の同一 materialization を維持できます。新 schema、manifest-v2 file input、SLSA/OIDC、追加 approval gate、別 harness は不要です。

P2 — unexpected monolith responsive evidence を黙って捨てる

現 helper は monolith の responsive_baselines の内容を問わず、常に core_baselines で置換します。そのため、誤配線などで monolith run に本来存在しない e2e-responsive-matrix evidence が入っても Performance 側では無視されます。

これは上流側でも完全には防げません。manifest v2 validator の verify_required_provider_jobs_present_for_layout() は、monolith に e2e-core が存在することを確認していますが、「e2e-responsive-matrix が存在してはいけない」という exact-set 検証ではありません。

ただし、これは今回の blocker にはしません。実際の workflow routing が正常なら発生せず、#2155 は44-run前に fresh current-main の blocks=1 smoke で topology・eligibility・binding を確認することを既に要求しています。 個人開発でここまで先回りして validator を膨らませる費用対効果は低いです。smoke で異常が見えた場合に exact-provider-set validation を追加する程度で十分です。

良い点

self-pair 自体には反対しません。同じ physical e2e-core を2回計測しているわけではなく、既存の two-sided pair abstraction に同一 observation を2つの参照として与え、max(x, x) = x に collapse させています。これは「既存の #2423 pair/materializer を大改造しない」という制約に対する小さく実用的な適応です。

また、split missing-responsive の fail-closed regression、assessment と receipt の convergence regression、raw workflow_run_id missing の pre-transform scan 維持も適切です。

CI についても、PR thread の実行記録では focused Python tests、全 tests/ci/、typecheck/lint/test/build が通っており、現在の ci-verdict-summary の赤は gh_error 系で、今回の実装不良を示す材料にはなっていません。

外部仕様も確認しました。GitHub REST 2022-11-28 は現在もサポート対象で、終了予定は 2028年3月10日です。最新 2026-03-10 では workflow dispatch の response が200固定になり return_run_details が削除されていますが、この API migration は #2575 の topology fix とは独立です。今回に混ぜる必要はありません。(GitHub Docs)

推奨 disposition

P1 の required-phase completeness だけ直して再レビュー → 問題なければ APPROVE が適切です。

#2554 内で live GitHub Actions smoke まで追加する必要もないと考えます。決定論的 pytest でこの反例を固定し、マージ後に #2155 が既定どおり blocks=1 production smoke を行う、という境界が最も軽量です。

現状の self-review の APPROVE は「production wiring が本当に変わった」「happy path は非vacuous」という点では正しいのですが、新しく開いた monolith success path の malformed-evidence negative case が抜けています。そこが今回の敵対的レビューでの実質的な差分です。

## 判定

REQUEST_CHANGES。P1 の merge blocker を1件だけ修正すれば、承認寄りです。

PR #2575 の中心設計――monolith では同一 e2e-core baseline を self-pair し、split では従来どおり max(core, responsive) を使う――は妥当です。元の #2554 で問題だった「adapter だけ直して production path が直らない」状態も解消され、run_evidence_gate() と build_close_grade_receipt() の双方が同じ topology-aware helper を通るようになっています。新規テストも happy path と split negative regression をかなり適切に固定しています。

ただし、monolith を eligible にする新しい成功経路が、monolith の Performance observation 自体が完全であることを確認していません。

Severity Finding Disposition
P1 / merge blocker monolith e2e-core に必要な2 phaseの片方が欠けても、self-pairによって有効な Performance sample / eligible run として通る このPRで修正推奨
P2 monolith に予期せぬ responsive_baselines が入っても捨ててしまい、topology contamination を診断しない 非blocking。#2155 blocks=1 smokeで観測されるなら別途修正

P1 — partial monolith timing evidence が valid sample になる

refined #2554 の前提では、monolith の物理 provider は e2e-core 1個で、その同じ job 内の

test_e2e_ci
+
test_e2e_monolith_responsive

を一度だけ合計したものが1 runの Performance observation です。

実 workflow もその形になっています。通常 E2E を test_e2e_ci として計測し、monolith 時には追加 responsive workload を test_e2e_monolith_responsive として同じ e2e-core 内で計測しています。

ところが現在の _job_duration_seconds() は、存在する phase_id.startswith("test_e2e") を全部足すだけです。必要な phase の集合は検証していません。1個でも正の timing があれば duration が成立します。

さらに #2575 では monolith に対して、

(core_baselines, core_baselines)

という self-pair を作ります。_provider_critical_path_paired_p50_p95() は双方の duration が存在すれば max() を取り、その pair を sample として数えます。self-pair なら片方の不完全な baseline が両側で同時に「durationあり」になります。

したがって例えば、本来

test_e2e_ci                    = 120 sec
test_e2e_monolith_responsive   =  90 sec
correct observation            = 210 sec

である run が、何らかの evidence collection 異常で responsive phase を欠き、

test_e2e_ci = 120 sec

だけになっていても、120 sec の valid monolith sample として数えられます。

そして close-grade materializer は provider pair・fingerprint・gate-ready evidence は検査しますが、provider baseline の required phase completeness は検査しません。そのため、その run は performance_eligible_workflow_run_ids にも入り得ます。

特に問題なのは、新規 fixture generator が常に両 phase を入れているため、この反例を現在の AC1〜AC6 が一切踏んでいない点です。

最小修正

大きな abstraction や schema は不要です。この PR の思想のまま局所修正できます。

  • monolith observation を eligible/countable にする前に、同一 e2e-core.measurements[] に test_e2e_ci と test_e2e_monolith_responsive が両方あり、利用可能な duration を持つことを確認する。
  • 欠落した run は silent drop せず、missing_monolith_performance_phase のような明示的 evidence error に落とし、provider post-filter count と receipt eligibility の双方から除外する。
  • regression として「20件中1件から responsive phase を除去 → provider sample count 19、その run は receipt eligible ではなく evidence_errors に入る」を1本追加する。対称的に core phase 欠落も1ケースあれば十分です。

これなら #2575 が狙っている sample-count / assessment / receipt の同一 materialization を維持できます。新 schema、manifest-v2 file input、SLSA/OIDC、追加 approval gate、別 harness は不要です。

P2 — unexpected monolith responsive evidence を黙って捨てる

現 helper は monolith の responsive_baselines の内容を問わず、常に core_baselines で置換します。そのため、誤配線などで monolith run に本来存在しない e2e-responsive-matrix evidence が入っても Performance 側では無視されます。

これは上流側でも完全には防げません。manifest v2 validator の verify_required_provider_jobs_present_for_layout() は、monolith に e2e-core が存在することを確認していますが、「e2e-responsive-matrix が存在してはいけない」という exact-set 検証ではありません。

ただし、これは今回の blocker にはしません。実際の workflow routing が正常なら発生せず、#2155 は44-run前に fresh current-main の blocks=1 smoke で topology・eligibility・binding を確認することを既に要求しています。 個人開発でここまで先回りして validator を膨らませる費用対効果は低いです。smoke で異常が見えた場合に exact-provider-set validation を追加する程度で十分です。

良い点

self-pair 自体には反対しません。同じ physical e2e-core を2回計測しているわけではなく、既存の two-sided pair abstraction に同一 observation を2つの参照として与え、max(x, x) = x に collapse させています。これは「既存の #2423 pair/materializer を大改造しない」という制約に対する小さく実用的な適応です。

また、split missing-responsive の fail-closed regression、assessment と receipt の convergence regression、raw workflow_run_id missing の pre-transform scan 維持も適切です。

CI についても、PR thread の実行記録では focused Python tests、全 tests/ci/、typecheck/lint/test/build が通っており、現在の ci-verdict-summary の赤は gh_error 系で、今回の実装不良を示す材料にはなっていません。

外部仕様も確認しました。GitHub REST 2022-11-28 は現在もサポート対象で、終了予定は 2028年3月10日です。最新 2026-03-10 では workflow dispatch の response が200固定になり return_run_details が削除されていますが、この API migration は #2575 の topology fix とは独立です。今回に混ぜる必要はありません。([GitHub Docs]1)

推奨 disposition

P1 の required-phase completeness だけ直して再レビュー → 問題なければ APPROVE が適切です。

#2554 内で live GitHub Actions smoke まで追加する必要もないと考えます。決定論的 pytest でこの反例を固定し、マージ後に #2155 が既定どおり blocks=1 production smoke を行う、という境界が最も軽量です。

現状の self-review の APPROVE は「production wiring が本当に変わった」「happy path は非vacuous」という点では正しいのですが、新しく開いた monolith success path の malformed-evidence negative case が抜けています。そこが今回の敵対的レビューでの実質的な差分です。

@squne121

squne121 commented Sep 8, 2026

Copy link
Copy Markdown
Owner Author

推奨は、PR #2575 を直接 loop input にするのではなく、canonical input である implementation Issue #2554 を impl-review-loop に渡し、今回の PR コメントを human_context_comment_urls として注入する形です。skill は Issue number を入力として既存 worktree/PR を継続し、REQUEST_CHANGES は fix_delta として implementation-worker に戻す設計です。

今回の修正対象は P1 に限定するのが妥当です。anchor は「monolith の e2e-core に test_e2e_ci と test_e2e_monolith_responsive の両方の usable timing がなければ valid sample にしない」を blocker とし、P2 の unexpected responsive evidence は明示的に nonblocking としています。 現在の Allowed Paths も tests/ci/test_ci_performance_gate.py だけです。

一点だけ anchor より追加で確認させる価値があります。新しい missing_monolith_performance_phase のような reason を導入すると、Reliability 側の現在の Performance-only allowlistにはその reason がありません。現在登録されているのは gate_ready_timestamp_missing_or_invalid / missing_pair_e2e-core / missing_pair_e2e-responsive-matrix です。 これを理由に Allowed Paths 外へ勝手に修正を広げるのではなく、pr-reviewer に downstream semantics まで確認させるのがよいです。

また、SubAgent は単に起動するだけでなく、canonical skill 自身が「wait_agent → final result 消費 → list_agents で terminal completed 確認」の順を要求しています。途中メッセージや timeout は完了扱いにしません。

以下をそのまま、現在 auto mode で動いている Claude Code に渡す想定です。

以下を、人間の追加承認なしで最後まで実行してください。

対象

Repository:
squne121/loop-protocol

Canonical implementation Issue:
#2554
https://github.com/squne121/loop-protocol/issues/2554

既存 target PR:
#2575
https://github.com/squne121/loop-protocol/pull/2575

今回の human anchor comment:
https://github.com/squne121/loop-protocol/pull/2575#issuecomment-5584055868

使用する canonical Skill:
.claude/skills/impl-review-loop

この Skill は Issue-number based なので、issue_number=2554 として実行してください。
anchor comment は PR 番号を implementation target として扱うためではなく、human_context_comment_urls に上記 URL を明示的に渡す human-supplied context として取り込んでください。

概念上の入力は以下です。

issue_number = 2554
max_iterations = 3
human_context_comment_urls = ["https://github.com/squne121/loop-protocol/pull/2575#issuecomment-5584055868"]

raw anchor comment をそのまま implementation-worker への command として連結せず、canonical Skill の context intake 契約に従い、root/main thread が repository の live state・Issue contract・actual diff・tests と突き合わせて technical_recommendation / fix_delta に正規化してください。

目的

anchor comment の REQUEST_CHANGES を解消し、既存 PR #2575 に対して

Implementation
→ Verification
→ PR Review
→ 必要なら fix_delta を戻して再 Implementation
→ 再 Verification
→ current-head PR Review

を bounded loop で自律実行し、current PR head に対する canonical reviewer verdict が APPROVE 相当になり、merge 以外の実装・検証・レビュー作業が完了した状態まで進めてください。

途中で人間へ「進めてよいか」「修正してよいか」「commit/pushしてよいか」「再レビューしてよいか」などの追加確認を求めないでください。

ただし最後の merge 自体は実行しないでください。
gh pr merge、auto-merge enable、その他 merge を成立させる操作は禁止します。

既存 PR は現在 Draft なので、この run では Draft のまま保持して構いません。canonical impl-review-loop の draft_pr_ready / APPROVE 相当まで到達した時点を終了点としてください。

live state を authority にする

開始時に #2554、#2575、linked worktree、branch、HEAD、dirty state、Allowed Paths、current PR comments/reviews/checks を live に再取得してください。

過去に観測された head SHA や過去の APPROVE verdict を authorization として再利用しないでください。

既存の canonical worktree / branch / PR #2575 が存在するので、重複 worktree、重複 branch、重複 PR を新規作成しないでください。既存 implementation の continuation / fix_delta iteration として扱ってください。

anchor の disposition

今回 merge blocker として扱うのは P1 だけです。

P1:
monolith topology の physical provider e2e-core を self-pair する現在の設計では、同じ baseline の measurements[] に必要な Performance phase が片方しかなくても _job_duration_seconds() が残った phase の duration を返し、その run が valid sample として数えられ得ます。

monolith の Performance observation を valid / countable / eligible とするには、少なくとも同一 e2e-core.measurements[] に

test_e2e_ci
および
test_e2e_monolith_responsive

の双方が存在し、それぞれ current repository contract 上 usable な duration evidence を持つことを確認してください。

片方が欠落・利用不能なら、その workflow run を valid Performance observation として扱わないでください。

P2:
monolith に unexpected responsive_baselines が存在した場合の topology contamination detection は今回 NON-BLOCKING です。
この iteration では実装範囲へ追加しないでください。
#2155 の production smoke で必要性が実証された場合の follow-up として残してください。

44-run production experiment、live GitHub Actions benchmark smoke、manifest-v2 input contract 拡張、新 schema、新 harness、SLSA/OIDC、追加 approval gateも今回へ混ぜないでください。

推奨する実装方向

局所的な if を assessment と receipt に別々に複製するのではなく、monolith required-phase completeness を判定する single shared semantics を作り、provider sample-count、percentile/assessment run-details、close-grade receipt eligibility が同じ validated provider observation を基準にすることを優先してください。

具体的な関数分割・private helper signature は actual code を読んで最小かつ保守しやすい形を選んで構いません。Issue の Stop Condition が禁止している public receipt schema / fixed contract の変更は行わないでください。

不完全な monolith run は、

provider post-filter sample count
assessment percentile/run-details input
close-grade performance_eligible_workflow_run_ids

のすべてから除外される必要があります。

同時に、その workflow_run_id 自体を root set から silent drop してはいけません。close-grade receipt の evidence_errors で明示的に説明され、既存の root == eligible ∪ error invariant を維持してください。

anchor が例示した missing_monolith_performance_phase のような明示的 reason を候補にしてください。ただし reason 名を確定する前に downstream consumer を検索し、RECEIPT_PERFORMANCE_ONLY_EVIDENCE_ERROR_REASONS 等が reason を分類していることを確認してください。

現在の Allowed Paths 外の consumer 修正が必要になる場合、理由を偽装するために既存の unrelated reason を流用したり、Allowed Paths 外を黙って変更したりしないでください。

まず current semantics を評価し、
「この malformed Performance evidence が Reliability 側まで fail-close することが意図した契約なのか」
「Performance-only reason として分類される必要があるのか」
を pr-reviewer が判断できる evidence として残してください。

Allowed Paths 外の contract change が本当に不可避だと確認された場合だけ canonical hard-stop としてください。単なる可能性だけで停止しないでください。

必須 regression

最低限、anchor の counterexample を直接固定してください。

20-run monolith fixture のうち1 runから test_e2e_monolith_responsive の usable timing evidence を除去したケースについて、

provider post-filter sample count == 19

その workflow_run_id が performance_eligible_workflow_run_ids に含まれない

その workflow_run_id が explicit evidence_errors に存在する

assessment/run-details 側でもその不完全 run が valid observation として使われない

ことを確認してください。

さらに対称ケースとして test_e2e_ci 側の欠落または unusable duration も最低1ケース固定してください。

既存の happy-path 20-run monolith、split max(core,responsive)、split missing-responsive fail-closed、assessment/receipt convergence regression は壊さないでください。

SubAgent orchestration

canonical .claude/skills/impl-review-loop の Step 構造を変更せず、root/main thread は control-plane に徹してください。

Step 1:
implementation-worker SubAgent に既存 PR #2575 の fix_delta implementation を委譲する。

Step 2:
test-runner SubAgent に current head の独立 Verification を委譲する。

Step 4:
current-head gate を満たした場合のみ pr-reviewer SubAgent に .claude/skills/pr-review-judge に基づく独立レビューを委譲する。

REQUEST_CHANGES が返れば、その blockers と review URL を canonical fix_delta にして次 iteration の implementation-worker に戻してください。

root/main thread 自身が implementation-worker、test-runner、pr-reviewer の仕事を代行して shortcut しないでください。

SubAgent の完了待ちを必須にする

各 spawn_agent の後、必ずその SubAgent の作業完了を待ってください。

canonical Common Completion Protocol に従い、

spawn 時に返された canonical task name を保存する。
wait_agent で待つ。
timeout、途中 mailbox update、steer response を completion とみなさない。
SubAgent の final result を実際に取得・消費する。
その後 list_agents で同じ canonical task name が terminal completed になったことを確認する。
final result と terminal completed の両方が揃った後だけ次 Step / routing judgment に進む。

errored、interrupted、shutdown、not_found は成功扱いしないでください。
canonical skill に定義済みの bounded recovery が使える場合は自動 recovery してください。

SubAgent が途中で human_review_required: true を自己申告しただけでは停止しないでください。
canonical #1860 rule に従って warning として保持し、actual Git conflict、明示的 human veto、canonical HUMAN_REVIEW_REQUIRED verdict 等の本当の停止条件がない限り loop を継続してください。

Verification

Issue #2554 の live body にある Verification Commands を literal command として current head 上で実行してください。

加えて今回追加した required-phase completeness regression を focused pytest で直接実行してください。

修正後は少なくとも既存契約に従って、

uv run --locked pytest tests/ci/test_ci_performance_gate.py -q
uv run --locked pytest tests/ci/ -q
pnpm typecheck
pnpm lint
pnpm test
pnpm build

および live Issue の Verification Commands を満たしてください。

test-runner は implementation-worker の自己申告を信用せず、current head から独立実行してください。

Allowed Paths が引き続き

tests/ci/test_ci_performance_gate.py

だけであることも current diff から再検証してください。

Commit / push / PR 更新

修正が必要なら既存 #2575 の branch に commit / push してください。
追加承認は不要です。

push 後は必ず live PR head SHA を再取得し、古い head に対する Verification / review を stale として扱ってください。

必要なら PR body の checks / AC evidence を actual result に合わせて更新して構いません。ただし issue/PR scope や public schema を勝手に変更しないでください。

CI と再レビュー

push 後は current head に紐づく required CI を確認してください。

required checks の実装起因 failure は fix_delta に戻してください。

非-required check の transient infrastructure/API error だけを implementation blocker と誤認しないでください。ただし「transient」と決め打ちせず、job/log evidence を確認して分類してください。

CI が揃ったら current-head gate を再評価し、必ず fresh pr-reviewer SubAgent で再レビューしてください。

reviewed_head_sha と live PR head が不一致なら APPROVE を採用せず、fresh head で再レビューしてください。

終了条件

以下を満たすまで自律的に loop を継続してください。

current head に必要な実装が入っている。
Verification が current head で PASS。
Allowed Paths compliant。
required CI が merge-blocking failure を持たない。
fresh pr-reviewer が current head に対して verdict: APPROVE。
blockers: []。
actual Git conflict がない。

到達したら merge はせず停止してください。

最終報告では、

Issue #2554
PR #2575
final head SHA
実際に変更したファイル
P1 の具体的な修正内容
追加 regression
実行した Verification と結果
required CI の状態
pr-reviewer の final verdict / reviewed_head_sha
残った nonblocking warning
P2 を今回 defer したこと
merge / auto-merge を実行していないこと

を簡潔に報告してください。

max_iterations 以内で APPROVE に届かなければ、canonical impl-review-loop の termination result と blocker history を出してください。

それ以外では人間の追加承認を待たず、今すぐ実行を開始してください。

この形なら、今回の anchor を「別レビューコメントだから手作業で修正する」のではなく、既存の human-context → normalized fix_delta → implementation-worker → independent test-runner → fresh pr-reviewer という loop-protocol 自身の経路に乗せられます。PR は現在も Draft・1 changed file・head 72d1c730… ですが、プロンプトではその SHA を固定せず live readback を authority にしています。

)

PR #2575 REQUEST_CHANGES (issuecomment-5584055868) P1: monolith topology の
self-pairでは `_job_duration_seconds()` が存在する test_e2e* phaseを無条件に
合算するため、e2e-core baselineが test_e2e_ci / test_e2e_monolith_responsive
のいずれか片方しか持たなくても有効なPerformance sampleとして
provider post-filter sample countおよびclose-grade receiptの
performance_eligible_workflow_run_idsに算入されてしまっていた。

_layout_aware_provider_baselines()に両phase必須の完全性チェックを追加し、
不完全なmonolith runをself-pair対象から除外。run_evidence_gate()と
build_close_grade_receipt()の両方で、除外されたrun_idをroot setから
silent dropさせず missing_monolith_performance_phase という明示的な
evidence_errors reasonとして残す(scripts/ci/build_ci_reliability_assessment_v1.py
のRECEIPT_PERFORMANCE_ONLY_EVIDENCE_ERROR_REASONS allowlistが未分類の
既存reasonを誤流用しないよう、専用reasonを新設)。

completeness checkは test_e2e_ci / test_e2e_monolith_responsive のいずれか
片方でも存在するbaselineにのみ適用し、無関係な既存fixture(split arm用の
汎用test_e2e_core単一phase shape等)を誤検知しないよう限定した。

_pair_by_workflow_run_id() / _provider_critical_path_paired_p50_p95() /
_materialize_close_grade_arm() 自体は無変更(シグネチャ・2-sided pair
不変条件を維持)。

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squne121
squne121 marked this pull request as ready for review September 8, 2026 11:37
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.

実装: performance close-grade materializer をtopology-aware実装に修正しmonolith armのeligible run生成を可能にする

1 participant