Repository navigation
fix: retrospective-run marker malformed comment を discard せず記録する - #2366
Conversation
buildRetroIndex() が normalizeRetrospectiveRunComment() の kind: 'blocked' 判定(構造的に無効な agent_retrospective_run_publication/v1 envelope、および marker prefix はあるが strict marker parse に失敗するケース)を黙って discard せず、retrospective_runs_blocked[](run_comment_url + reason)へ記録するよう 変更する。retrospective_runs_blocked が非空の場合、既存 blockedReasons が空 である限り generation_verdict を partial に反映し、index 生成・upsert 自体は 継続する。extractRetrospectiveRunPayload() は marker prefix はあるが strict parse に失敗する first line を kind: 'blocked' / reason: 'retrospective_run_marker_malformed' として返すよう拡張する。 detectSchemaMigrationRequirement() の allowedKeys と docs/schemas/agent-retro-index.schema.json へ optional additive property として retrospective_runs_blocked を追加する。既存 blockedReasons 由来の blocked semantics と publication_digest の暗号学的検証は変更しない (PR #2304 の pr-reviewer 非ブロッキング指摘 P0-7 関連の解消)。 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #2366 closed). |
PR Review 判定 (impl-review-loop iteration 0)Mergeability
Evidence Check
Blockersなし Non-blockers / Warnings
verdict: APPROVE
reviewed_head_sha: "ec924826a51e9f5ef1191f3bc3849d910521f86e"
blockers: []
warnings:
- "ci_test_performance_advisory_v1_non_blocking_docs_schemas_path"
- "allowed_paths_gate_advisory_contract_source_metadata_missing" |
敵対的レビュー結果Verdict: レビュー対象は current head 設計の大部分は妥当です。しかし、Issue #2308 の主目的である「marker prefix が見えている malformed comment を silent discard しない」という契約を、まだ破る入力が1種類残っています。 P1 —
|
PR #2366 への human REQUEST_CHANGES fix_delta。RETROSPECTIVE_RUN_MARKER_PREFIX の ECMAScript \b は両側が word 文字だと発火しないため、 `v1repository_id=...` や `v1_repository_id=...` のような区切り文字を欠いた malformed マーカーが prefix 判定をすり抜け ignored のまま kind: 'blocked' に 昇格しなかった(AC3 違反)。`(?![0-9])` の負の先読みに置き換え、v10 等の 将来バージョンとの区別を保ったまま該当パターンを blocked に分類する回帰 テストを追加する。
PR Review 判定 (impl-review-loop iteration 2)人間の adversarial review(#2366 comment 5451100881, REQUEST_CHANGES: fix_delta 内容
Mergeability
Evidence Check
Blockersなし Non-blockers / Warnings
verdict: APPROVE
reviewed_head_sha: "42046862be5a68c849885a463c7449700f2f112d"
blockers: []
warnings:
- "head_sha_advanced_twice_via_external_update_branch_merges_during_review_window"
- "ci_test_performance_advisory_v1_non_blocking_docs_schemas_path"
- "non_required_checks_pending_at_review_time_not_blocking" |
|
3ジョブの関係は明確です。
さらに、失敗テストには構造的なフレーク要因があります。テストは したがって推奨順位は 「#2366を修正しない → 対象テストを再現調査 → フレークならCI再実行 → 恒久対策は別スコープ」 です。単に0.3秒を数秒へ伸ばすより、「プロセス起動を同期確認してから cancellation を発火させる」テストへ直す方が妥当です。PR #2366 の最新レビューでも current head の本体変更は APPROVE され、当時 Claude Code には次を渡すのがよいです。サブエージェントを2系統に分け、両方の完了を必ず待ってから判断するよう明記しています。 PR #2366 の GitHub Actions failure を調査し、適切な推奨アクションまで実行してください。 対象:
既知の観測:
重要な進行ルール最初に独立したサブエージェントを最低2つ起動してください。 SubAgent A: CI root-cause investigatorread-only で以下を調査する:
特に次を判定する:
コード変更はしない。 SubAgent B: PR scope / regression investigatorread-only で以下を調査する:
コード変更はしない。 必須: SubAgent completion barrier2つのサブエージェントを起動したら、両方が完全に終了して最終レポートを返すまで待つこと。 片方だけの結果で次工程へ進まない。 両方のレポートを受領してから、main agent自身で証拠を照合して最終判断すること。 再現調査SubAgent完了後、current PR headを再確認する。 gh pr view 2366 --json headRefOid,baseRefOid,headRefName,baseRefName,isDraft,mergeStateStatusrun 33163197490 が対象としていた head: headが進んでいた場合は、古いSHAを現在の事実として扱わずcurrent headで再評価する。 まず production code を変更せず focused test を再現する。 uv run --locked pytest \
.claude/skills/gemini-cli-headless-delegation/tests/test_fan_out_process_lifecycle.py::test_timeout_termination_recorded \
-vv単発PASSだけでflake認定しない。
必要に応じて20回程度繰り返す。ただし単に回数を増やすことより、failure pathのイベント列を採取することを優先する。 判定を以下の2経路に分ける。 Case A: process_start が存在しないかつ outcome が これは production invariant violation ではない。
この場合:
恒久対策案としては、単純な timeout 値増加より、 例えば:
overall timeout watcher 自体のテストと、 ただしこの修正は Issue #2308 / PR #2366 の Allowed Paths 外なので、 Case B: process_start が存在するにもかかわらず process_exit が欠落する場合: production process-lifecycle bug の可能性がある。 以下を追跡する:
この場合も #2366 へ直接修正を混ぜない。 PR #2366に対するアクション原則: root failure が Case A の timing flake であり、 GitHub CLI/APIで job rerun が可能なら、 を再実行する。 再実行後は dependent result を最後まで確認し、
再実行でも同じテストが失敗した場合は、rerun連打をしない。 恒久修正が必要な場合Allowed Paths 外修正が必要と判定したら、 以下を最終報告する:
別Issueの自動作成や別branchへの実装を既存repo policyが明示的に許可していない場合は、勝手に始めず、 禁止事項
最終出力以下の形式でまとめる:
最も重要なのは、 このプロンプトなら、再実行だけで偶然緑にして終了するのではなく、「before-Popen cancellation ならテスト側の同期不足」まで確認してから判断させられます。現時点では、#2366へのコード追加修正よりこの切り分けを優先するのが妥当です。 |
…2373) * fix: fan-out timeout/cancellation テストを readiness sentinel 同期へ書き換える (#2371) PR #2366 の CI 安定化調査で発見した readiness race に依存する fan-out timeout/cancellation テストを、pid sentinel 同期と責務分離された assert へ 書き換える。 - test_timeout_termination_recorded を test_running_process_cancellation_records_sigterm へ rename し、固定の overall_timeout_sec=0.3 deadline watcher 経路(Popen 前に発火しうる)で はなく、pid_file readiness sentinel を確認してから手動 cancel_event.set() する設計に変更。process_start/process_exit の PID 一致と termination_reason も assert する。 - test_sigkill_escalation_recorded も同じ readiness sentinel helper を使用 するよう変更し、time.sleep(0.3) による readiness race を除去。 - test_subprocess_runner_terminates_process_group_on_timeout の false-green (Popen 未到達でも ok is False と "timeout" in failure_class だけで PASS してしまう構造)を、pid sentinel で実 subprocess 起動を確認し、cancel 後に 実プロセスが本当に消えたことまで確認する形に修正。 - test_overall_timeout_cancels_pending_and_terminates_running を test_overall_timeout_cancels_pending_subtasks へ rename し、 overall_timeout_reached event と pending subtask の cancellation のみを assert する形に整理(起動済み process の termination までは主張しない)。 - 上記いずれも sentinel timeout・assertion failure・thread 内例外の全経路で thread / child process を finally で cleanup し、thread.join() 後に not thread.is_alive() を assert する。 production code (fan_out_orchestrator.py) には diff なし。 Co-Authored-By: Claude Sonnet 5 <[email protected]> * fix: fan-out cancellation テストの finally cleanup を cancel_event 経路から独立させる OWNER 敵対的レビュー(PR #2373, reviewed_head_sha f664bfa)の REQUEST_CHANGES を反映する。 - test_running_process_cancellation_records_sigterm / test_sigkill_escalation_recorded / test_subprocess_runner_terminates_process_group_on_timeout の finally cleanup が、 検証対象そのものである cancel_event 協調キャンセル経路にのみ依存しており、runner thread 内で無処理例外が発生した場合や cancel_event セット後も runner がハングした 場合に non-daemon thread と child process がリークしうる構造上の欠陥を修正(P1)。 thread 内例外を別 list に捕捉し、finally 内で ctx.terminate_all(grace_period=0.1) を cancel_event 経路とは独立に必ず呼び、thread がまだ生きている場合または thread 内 例外が捕捉された場合のみ child_pid ベースの test-only fallback(os.getpgid 一致確認 後 os.killpg SIGKILL)で強制終了する。 - test_sigkill_escalation_recorded に process_start の件数(1件)と sentinel PID との 一致 assert を追加し、SIGTERM 側テストと対称な lifecycle pairing 検証にする(P1)。 Issue #2371 の全 Verification Commands を再実行して確認済み: - pytest 通常実行 50 passed - pytest -n4 --dist load 50 passed - 修正対象 3 テストのみ fresh pytest process で 20 回連続実行し flake なし - fan_out_orchestrator.py に diff なし(AC8) - ruff check クリーン Related: #2371 --------- Co-authored-by: Test <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
scripts/agent-logs/lib/retro-index-builder.mjsのbuildRetroIndex()が、malformed / structurally-invalid なagent_retrospective_run_publication/v1marker 付き retrospective-run コメント(normalizeRetrospectiveRunComment()がkind: 'blocked'を返すケース、および marker prefix はあるが strict marker parse に失敗するケース)を黙って discard せず、retrospective_runs_blocked(run_comment_url+reasonを保持する配列)として記録するよう変更した。retrospective_runs_blockedが非空の場合、既存blockedReasonsが空である限りgeneration_verdictを少なくともpartialに反映し、index の生成・upsert 自体は継続する(PR 実装: agent-retrospective の run 永続化と agent_retro_index/v1 統合を実装する #2304 の pr-reviewer 非ブロッキング指摘 P0-7 関連の解消。Closes 実装: retro-index-builder が malformed/unverifiable な run comment を discard せず generation_verdict に反映する #2308)。Checks
pnpm typecheckpnpm lintpnpm testpnpm buildSchema Change Applicability
schema_changedocs/schemas/agent-retro-index.schema.jsonへ optional additive propertyretrospective_runs_blockedを新規追加する schema 変更のため。Schema Consumer Inventory
変更対象 schema:
docs/schemas/agent-retro-index.schema.json(agent_retro_index/v1、additionalProperties: falseの closed schema への additive property 追加)before/after 差分:
retrospective_runs_blockedは省略可能な additive フィールドであり、既存 artifact(本フィールド欠落)は引き続き schema-valid のままである。Consumer 列挙(rg コマンド例と結果):
Consumer 更新状況:
scripts/agent-logs/lib/retro-index-builder.mjsretrospective_runs_blockedを生成しdetectSchemaMigrationRequirement()のallowedKeysへ追加(本 PR の主対象)tests/agent-logs/retro-index-schema.test.tsajv/dist/2020.js) で schema ファイルを直接 compile し、retrospective_runs_blockedあり/なし artifact・欠損reasonfixture・buildRetroIndex()の実出力を schema validation する回帰テストを追加tests/agent-logs/retro-index-update.test.tsbuildRetroIndex()経由のretrospective_runs_blocked生成・generation_verdict反映の behavior-based regression test を追加scripts/lib/agent-run-report-validation.mjs(validateRetroIndexAgainstSchema())tests/agent-run-report-schema.test.tsの既存 fixture で回帰なしを確認)tests/agent-run-report-schema.test.tsvalidateRetroIndexAgainstSchema(createValidRetroIndex())が既存 fixture(retrospective_runs_blocked欠落)でvalid: trueのまま(pnpm test全件 PASS で確認)docs/dev/agent-retro-index.mddocs/schemas/agent-retro-index.schema.jsonを参照」という参照のみで、フィールド一覧を複製していないため追随不要docs/dev/agent-run-report.mdtests/agent-logs/chatgpt-context-marker-mode.test.ts/tests/agent-logs/chatgpt-retro-context-marker.test.tsschema_ref文字列リテラル(docs/schemas/agent-retro-index.schema.json#agent_retro_index/v1)のみを参照しており、フィールド構造には依存しないCompatibility Decision(互換性判定)
additivebackward_compatiblenoN/Aretrospective_runs_blockedは top-level の任意 additive property であり、省略時も schema-valid(既存 artifact に影響なし)。既存blockedReasons/entries[](agent_run_report/v1側)のblockedsemantics・publication_digestの暗号学的検証ロジックは変更していない。Safety Claim Matrix
.claude/skills/**/.github/workflows/**のいずれにも該当しない(scripts/agent-logs/lib/retro-index-builder.mjs、docs/schemas/agent-retro-index.schema.json、テストファイルのみの変更)ため safety-sensitive ではない。Notes
M4: Upgrade Loopの境界外の agent-ops governance/observability 改善であり、milestone スコープには影響しないnot_applicable(静的 Vitest unit test のみで完結。Issue 本文の decision に従う)scripts/agent-logs/lib/retro-index-builder.mjs、docs/schemas/agent-retro-index.schema.json、tests/agent-logs/retro-index-update.test.ts、tests/agent-logs/retro-index-schema.test.ts)内のみを変更。Out of Scope(既存blockedReasons由来のblockedsemantics 変更、publication_digestの cryptographic 再計算・verifier 実装)はいずれも実施していない。docs/schemas パスに対する CI_TEST_PERFORMANCE_ADVISORY_V1(block: false)が発火したが、docs/schemas/agent-retro-index.schema.jsonはデータスキーマ定義であり CI/test-lane 設定ではないため non-blocking advisory として扱った。受け入れ条件の達成状況
buildRetroIndex()の戻り値オブジェクトにretrospective_runs_blocked(run_comment_url+reasonを保持する配列)フィールドが追加され、normalizeRetrospectiveRunComment()がkind: 'blocked'を返す malformed / structurally-invalid な run comment が記録される —scripts/agent-logs/lib/retro-index-builder.mjs731行目retrospective_runs_blocked: retrospectiveRunsBlockedで確認(rg -n "retrospective_runs_blocked" scripts/agent-logs/lib/retro-index-builder.mjs)retrospectiveRunsBlockedが非空の場合、既存blockedReasonsが空である限りgeneration_verdictがpartialになる(blockedReasons.length > 0の場合は従来通りblocked優先)。retrospective_runs_blockedのみを理由に index の生成・upsert 自体は中断されない — 726行目のgeneration_verdict三項判定にretrospectiveRunsBlocked.length > 0が組み込まれていることで確認(rg -n "retrospectiveRunsBlocked.length" scripts/agent-logs/lib/retro-index-builder.mjs)<!-- agent_retrospective_run:v1)はあるが strict marker parse に失敗する comment(例:idempotency_key欠損)がkind: 'ignored'ではなくkind: 'blocked'/reason: 'retrospective_run_marker_malformed'として記録される。marker prefix を一切持たない通常 comment は従来通りignoredのまま — 355行目return { kind: 'blocked', reason: 'retrospective_run_marker_malformed' }で確認(rg -n "retrospective_run_marker_malformed" scripts/agent-logs/lib/retro-index-builder.mjs)docs/schemas/agent-retro-index.schema.jsonにretrospective_runs_blockedが optional additive property として追加され、新フィールドを含む artifact が schema validation とdetectSchemaMigrationRequirement()の両方を通る(既存 artifact に本フィールドが欠落していても schema-valid のまま)— schema 26行目に"retrospective_runs_blocked"プロパティ定義、builder 751行目allowedKeysに同キーが追加済み(rg -n "retrospective_runs_blocked" docs/schemas/agent-retro-index.schema.json)valid entry + malformed runfixture でentries[]を失わずretrospective_runs_blockedが1件記録されgeneration_verdict=partialになる、marker 自体が malformed なケースも記録される、marker のない通常 comment はignoredのまま、正常 run のみなら従来通りgeneration_verdict=completeになる、の behavior-based regression test がtests/agent-logs/retro-index-update.test.tsおよびtests/agent-logs/retro-index-schema.test.tsに追加され PASS — 対象2ファイルの focused test run で 2 files / 23 tests PASS(下記「検証コマンド結果」参照)pnpm testが全件 PASS — 112 files / 1887 tests PASS(下記「検証コマンド結果」参照)検証コマンド結果
検証は head
0a580ab5db69af438adcd4952993a44fa5398cf0を detached checkout した独立 worktree で実行した。Allowed Paths 遵守
変更ファイル(
gh pr view 2366 --json filesで確認)は以下の4件であり、Issue #2308 の Allowed Paths と完全一致する。範囲逸脱(scope creep)はない。scripts/agent-logs/lib/retro-index-builder.mjsdocs/schemas/agent-retro-index.schema.jsontests/agent-logs/retro-index-update.test.tstests/agent-logs/retro-index-schema.test.tsIssue #2308 が定義する Allowed Paths(4件)は次の通りである:
変更ファイル一覧との差分なし(4/4 一致、Allowed Paths 外の変更なし)。