Repository navigation
Closed
Labels
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "nonzero.py と timeout.py の transport failure を、full-adapter wall-clock 閾値ではなく固定 reason code・outer process result・fail-open output・artifact absence・redaction により決定論的に検証する"
change_kind: codeParent Issue
なし(単独改善)
Parent Goal Ref
- Goal: N/A(単独改善のため親 Issue なし)
- Desired Destination: N/A
Current Validated Scope
tests/hooks/codex-scope-rollup-capture.test.tsのit('GIVEN transport fixture failures WHEN the adapter runs THEN transport failures are bounded and redacted', ...)(329-348行目)のみを対象とする
Remaining Parent Gaps
なし
Runtime Verification Applicability
decision: immediate
applicable_acs:
- AC1
- AC2
- AC3
- AC4
- AC5
- AC6
execution_environment:
cli_tools:
- node
- pnpm
auth_required: false
network_required: false
skip_conditions:
- "pnpm / vitest が実行環境に存在しない場合は SKIP ではなく environment blocked として扱う"
fallback_policy:
fallback_success_is_pass: false
notes: "fallback 経由の成功を PASS に変換しない"
artifact_requirements:
- "pnpm exec vitest run 実行ログ(--reporter=verbose)"
- "5回連続実行それぞれの command / exit code"Outcome
nonzero.py と timeout.py の transport failure が、it.each による独立した2ケースとして実行され、capture_nonzero / capture_timeout の正しい分類、adapter プロセスの正常終了(result.error/result.signal/result.status)、fail-open output({"continue":true})、capture artifact 非生成、child output の非漏洩が検証される状態。elapsedMs(full-adapter wall-clock)は受け入れ判定に使用しない。
In Scope
- 対象
itブロック(329-348行目)をit.eachによりnonzero.py/timeout.pyの2ケースへ分割する - ケースごとに固定 reason code(
scope-rollup capture skipped (capture_nonzero)/scope-rollup capture skipped (capture_timeout))を検証する result.error === undefined、result.signal === null、result.status === 0を検証する{"continue":true}、capture artifact(.txt)非生成、fixture canary / payload 本文の非漏洩を検証する- 対象テストから
elapsedMsの上限 assertion(toBeLessThan(6500))を削除し、診断ログとして残す場合も assertion には使用しない - Vitest の各ケース timeout を outer adapter watchdog(
spawnSyncのtimeout: 7000)より大きい値にする - focused test を5回連続実行し、全回 PASS することを確認する
Out of Scope
- production capture timeout(
3,500ms)の変更 - process-group grace(
500ms)の変更 - fixture(
nonzero.py/timeout.py)の sleep / exit behavior の変更 codex-hook-adapter.mjsの構造変更(runScopeRollupCapture()の抽出等)- manifest flow / post-run verifier(
verifyCodexPostRun())の高速化・timeout 追加 codex-scope-rollup-capture.test.ts内の他のitブロック(350行目以降の'timeout terminates process tree without late write'等)の timing assertion- CI ワークフロー(
.github/workflows/**)の変更 - performance non-regression の主張(
elapsedMsは診断ログとしてのみ残してよいが、assertion には使用しない)
Acceptance Criteria
- AC1:
nonzero.pyとtimeout.pyがit.eachにより2件の独立した名前付きテストとして定義されている - AC2:
nonzero.pyはcapture_nonzero、timeout.pyはcapture_timeoutの固定 reason code を生成し、両ケースでテストが検証する - AC3: 両ケースで
result.errorが未設定、result.signalがnull、result.statusが0であることをテストが検証する - AC4: 両ケースで stdout が exact
{"continue":true}、capture directory に.txtが0件、fixture canary と payload 本文が stderr に含まれないことをテストが検証する(elapsedMsの上限 assertion は使用しない) - AC5: focused transport test(
-t "transport fixture")を5回連続実行し、全5回とも exit code 0 で PASS する - AC6:
pnpm typecheck,pnpm lint,pnpm test,pnpm buildが PASS する
Verification Commands
# AC1
# preflight-scope: pr_review_only
$ rg -n "it\.each" tests/hooks/codex-scope-rollup-capture.test.ts
# AC2
# preflight-scope: pr_review_only
$ rg -n "capture_nonzero" tests/hooks/codex-scope-rollup-capture.test.ts
$ rg -n "capture_timeout" tests/hooks/codex-scope-rollup-capture.test.ts
# AC3
# preflight-scope: pr_review_only
$ rg -n "result\.error" tests/hooks/codex-scope-rollup-capture.test.ts
$ rg -n "result\.signal" tests/hooks/codex-scope-rollup-capture.test.ts
# AC4
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# AC5
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# preflight-scope: pr_review_only
$ pnpm exec vitest run tests/hooks/codex-scope-rollup-capture.test.ts -t "transport fixture" --reporter=verbose
# AC6
$ pnpm typecheck
$ pnpm lint
# preflight-scope: pr_review_only
$ pnpm test
$ pnpm buildAllowed Paths
- tests/hooks/codex-scope-rollup-capture.test.ts
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- production の capture timeout
3,500ms/ grace500ms契約変更が必要になった場合 codex-hook-adapter.mjsの構造変更が必要と判明した場合- capture phase と manifest/post-run phase の個別時間計測が必要になった場合(production seam 抽出は別 Issue とする)
codex-postrun-verifier.mjsの Git subprocess timeout または artifact traversal bound が必要と判明した場合(別 Issue とする)result.errorが outerspawnSynctimeout を示し、test-only watchdog の値変更が必要と判明した場合は、error.code/signal/ elapsed / 環境情報を記録して Scope Delta を更新する- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- TypeScript
- Vitest BDD(
it.each) - Node.js child_process(spawnSync)
Required Design References
docs/dev/test-lane-policy.md— テスト実行レーン方針tests/CLAUDE.md— テスト戦略(GIVEN/WHEN/THEN、境界値・異常系網羅方針)
Scope Delta(任意)
N/A
Notes for Reviewer
本 Issue は Issue #1283 の issue-refinement-loop 完了処理中に発見された。issue-contract-review の pnpm test regression gate として、この無関係な flaky/脆弱テストが Issue #1283 の CONTRACT_REVIEW_RESULT_V1.status: go 確定をブロックした。
本文は OWNER による敵対的レビュー(#1727 anchor comment)を反映して全面改訂した。改訂理由:
- 旧 AC1 の Verification Command(
rg -n "toBeLessThan\(6500\)")は修正前に exit 0・修正後に exit 1 となる逆向き(false-green)契約だったため、it.each分割・固定 reason code・result.error/result.signal/result.statusを直接検証する behavior contract へ置き換えた。 - 旧 Allowed Paths(
tests/hooks/fixtures/scope-rollup-capture/*.py)は実在しないパスだった(実際の配置はtests/fixtures/hooks/scope-rollup-capture/*.pyで、adapter 自身もこちらを固定参照している)。今回の最小修正では fixture 変更は不要と判断し、Allowed Paths をtests/hooks/codex-scope-rollup-capture.test.ts単一ファイルに絞った。 - 旧 Out of Scope は adapter 実体を
scripts/agent-hooks/配下と誤記していた(実体はscripts/session-recording/codex-hook-adapter.mjsで、リトライ/バックオフ処理は存在しない)。この誤記を削除した。 elapsedMs(runAdapter()の計測範囲、tests/hooks/codex-scope-rollup-capture.test.ts140-155行目付近)は capture transport 単体でなく、adapter 起動からrunManifestFlow()/verifyCodexPostRun()までの full-adapter integration latency を計測している。閾値の引き上げは post-run verifier 等の性能劣化を transport のマージンとして吸収してしまうため、elapsedMsを semantic assertion から除外する方針とした。- Issue 実装: codex-scope-rollup-capture.test.ts の source-bound eligibility テストに明示的 timeout を設定する #1693 / PR test: source-bound eligibility テストに明示的 timeout を設定する #1699 で、同じテストファイルの集約 timeout 問題を閾値引き上げでなく
it.each分割で解決した先例(sourceBoundRejectionCases)が既に存在し、同じ設計原則を適用する。 - PR evidence には
performance_claim: no_claimを明示し、5回連続実行はあくまで stability smoke であり性能証明ではないことを PR 本文に記録すること。
上記の技術的主張(Allowed Paths 不整合、adapter パス誤り、elapsedMs 計測範囲)は、issue-refinement-loop の codebase-investigator による独立検証で確認済み。
Activity
squne121 commentedon Jul 25, 2026
Scope Overlap Preflight 結果(記録)
check_issue_overlap.py --fail-on-unsafeの結果はdecision: overlap_requires_comment(policy_class: C1、reason_code: allowed_paths_overlap)でした。tests/hooks/codex-scope-rollup-capture.test.ts,tests/hooks/fixtures/scope-rollup-capture/nonzero.py,tests/hooks/fixtures/scope-rollup-capture/timeout.pynon_conflict_reason: いずれの候補も Allowed Paths に汎用的な
tests(bare ディレクトリ全体)を含んでいるだけで、本 Issue が対象とする具体ファイル(tests/hooks/codex-scope-rollup-capture.test.ts等)に言及した実装作業ではない。#1390(visual diff triage)、#1176(M4 Upgrade Loop parent tracker)、#420(playtest-log schema)はいずれも無関係な機能領域であり、false positive と判断した。edit_intent: 本 Issue は
tests/hooks/codex-scope-rollup-capture.test.ts内の1テストケースの timing assertion のみを対象とし、他候補 Issue の実装作業と競合しない。dependency ordering: なし(各候補との依存関係なし、
dependency_relation.relation: none)。squne121 commentedon Jul 25, 2026
敵対的レビュー — Issue #1727
判定
REQUEST_CHANGES— 現状の Issue 契約のまま実装を開始すべきではありません。「不安定な wall-clock assertion を除去する」という目的は妥当です。しかし現行 AC1 は、
6500を6501、6999、60000のいずれかへ変更するだけでも達成できます。しかも対象のelapsedMsは capture transport 単体ではなく、adapter 起動、capture、manifest 生成、manifest 書き込み、post-run verifier の全処理時間です。この契約では原因を分離せず、別フェーズの遅延を大きな閾値で隠す false-green が成立します。技術的な系譜は次です。
PR #1699 では、OWNER の変更要求を受けて集約 timeout を撤去し、
it.eachによるケース分割へ修正されています。同 PR の実測では対象ファイルを3回連続実行して全回 PASS、最重量の transport 系ケースも約3.5~3.7秒でした。今回も同じ設計原則を適用すべきです。Blocker 1 — AC1 と Verification Command が false-green かつ逆向き
現行 AC1 は、要求しているのが「
6500から値が変わったこと」だけです。振る舞いではなくソース上の数値リテラルを受け入れ条件にしています。さらに AC1 の Verification Command は次です。
これは修正前には exit code 0、正しく assertion を削除した後には exit code 1 になります。つまり、通常の「コマンド成功を PASS とする」検証系では結果が逆です。AC2 も「5回連続」と記載しながら、Verification Commands には1回分しかありません。
リポジトリ自身のテスト方針も、「実装詳細ではなく入出力の振る舞いをアサーションする」と定めています。数値リテラルの変更確認は、この方針と一致しません。
必要な修正
AC1 は次のような behavior contract に変更すべきです。
nonzero.pyがcapture_nonzeroとして処理された。timeout.pyがcapture_timeoutとして処理された。両ケースで adapter 自体は outer watchdog に到達していない。
hook は fail-open の
{"continue":true}を返した。fixture 出力、payload 本文、絶対パスを漏洩していない。
capture artifact を誤生成していない。
Blocker 2 — Allowed Paths が実在しない
Issue が許可している fixture パスは以下です。
しかし実際の配置は以下です。
adapter 自身も後者を fixture root として固定しています。
また、Out of Scope には adapter が
scripts/agent-hooks/配下にあり、「リトライ/バックオフロジック」を持つと書かれていますが、実体はscripts/session-recording/codex-hook-adapter.mjsです。対象の capture transport にリトライ/バックオフ処理はありません。このままでは、Issue が許可した fixture 修正を行おうとすると実在しないパスを編集することになり、実在パスを編集すると Stop Condition の「Allowed Paths 外」に該当します。唯一の Issue コメントも同じ誤ったパスを前提に overlap 判定しており、直接の技術的関連である #1527、#1534、#1693、#1699 を依存関係として扱っていません。
推奨
fixture の編集は今回不要です。Allowed Paths は次の1ファイルだけに狭めるべきです。
Blocker 3 —
elapsedMsは transport の時間を測っていないrunAdapter()の計時範囲は、外側の Node プロセスをspawnSync()で開始する直前から、そのプロセスが完全終了するまでです。timeout: 7000も capture producer ではなく、adapter プロセス全体に対するものです。一方、adapter の実際の流れは次です。
capture の timeout/nonzero は fail-open であり、その後に
runManifestFlow()が必ず実行されます。さらに post-run verifier は、対象リポジトリに対して以下を同期実行します。
git status --porcelain=v1 -z --untracked-files=allartifacts/以下の再帰走査git for-each-refgit config --get-regexp .これらには個別 timeout や走査件数上限がありません。dirty worktree、untracked file 数、
artifacts/の規模、Git の応答時間によって、capture transport と無関係にelapsedMsが増加します。したがって、現在の
は、次のどれが遅かったのかを区別できません。
Issue の名称と Goal は「transport fixture failure」ですが、実際の metric は full-adapter integration latency です。閾値だけを引き上げると、post-run verifier の性能劣化を transport のマージンとして吸収してしまいます。
Blocker 4 — 現在のテストは fixture 経路が実際に通ったことを証明していない
対象テストが検証しているのは以下だけです。
capture_nonzeroとcapture_timeoutのどちらも assertion していません。また、capture directory に.txtが作られていないことも確認していません。そのため、例えば以下の誤実装でも PASS し得ます。
test fixture override が無視され、canonical producer が正常終了した。
eligibility/readiness gate が fixture 起動前に skip した。
timeout.pyが起動されず、別の早期 return を通った。adapter が transport failure を誤って
capture_okと分類した。最低限、ケースごとに次の固定 diagnostic を要求する必要があります。
adapter は既にこの固定 reason code を出力する実装になっています。
Major 1 — 「恒常的 FAIL」という前提は証拠不足
Issue は「別コミット・別 worktree copy で3回すべて失敗した」と記載していますが、次の情報がありません。
各実行の commit SHA
Node、pnpm、Vitest、Python のバージョン
OS / WSL / CI runner
result.elapsedMsresult.statusresult.signalresult.error?.codestderr の固定 reason code
dirty/untracked file 数
artifacts/のファイル数focused test か full suite か
assertion failure か
spawnSynctimeout かVitest timeout か
一方、直前の PR #1699 では、同じテストファイルを3回連続実行して全回 PASSし、transport 系の最重量ケースは3.5~3.7秒と報告されています。
また、#1727 起票直前に current main へ入った PR #1723 のレビューでは、
testjob を含む required CI 全体が green と確認されています。さらに #1693 自身でも、変更を含む root worktree では失敗し、clean detached worktree では PASS したという環境依存の差が記録されています。
これは #1727 の再現報告が誤りだという意味ではありません。ただし、「すべての正規環境で恒常的に失敗する」と確定した証拠にはなっていません。より正確な Goal は次です。
Major 2 —
nonzeroとtimeoutを1件の test で集約すべきではない現在は、性質の異なる2経路を1件の
it内で順番に実行しています。nonzero.pyは即時の exit code 9、timeout.pyは30秒 sleep に対する内部 timeout を検証するものです。失敗原因、所要時間、期待 reason code が異なるため、独立した名前付きテストにすべきです。Vitest 公式も、同じテストを異なる入力で実行する用途として
test.each/it.eachを提供しています。(Vitest)これは #1693 / PR #1699 で既に採用された修正方針でもあります。
Major 3 — 三層 timeout の責務が混ざっている
現在の timeout は以下です。
production capture の 3,500ms+500ms は policy に明記された契約です。
production Codex hook 自体は30秒です。
問題は、outer
spawnSyncと Vitest timeout を同じ7秒にしていることだけではありません。Node.js のspawnSync()は event loop をブロックし、timeout 後に kill signal を送っても、子プロセスが完全終了するまで戻らない仕様です。結果にはstatus、signal、timeout/failure 時のerrorが提供されます。(Node.js)したがって、Vitest timeout を
spawnSyncの外側に置いただけでは、独立した hard-kill boundary になりません。これは Node の同期ブロッキング仕様から導かれる推論です。Vitest の Node 環境における既定 test timeout は5,000msですが、同期 call のプロセスツリー終了を保証する仕組みではありません。(Vitest)今回の最小修正では
production の
3,500 / 500は変更しない。elapsedMsを semantic assertion から外す。result.error、result.signal、result.statusを検証する。Vitest の各ケース timeout は outer watchdog より十分大きくする。
outer watchdog の引き上げは、実際に
result.error.codeが timeout を示した証拠がある場合だけ行う。という順序が妥当です。
Major 4 — fixture の遅延時間を変更すべきではない
timeout.pyは意図的に30秒 sleep しています。production capture timeout 3.5秒を十分に超え、必ず timeout 経路へ入れるための fixture です。これを5秒や6秒へ短縮しても full-adapter の不安定性は解決しません。むしろ、将来 production timeout が変更された際に fixture が timeout 経路へ入らなくなる境界リスクを増やします。
nonzero.pyも stdout/stderr へ明示的な canary を書き、exit code 9 で終了する redaction fixture です。内容を変更する必要はありません。したがって今回の Allowed Paths から両 fixture を外すべきです。
Major 5 — 5回連続実行は stability smoke であり、性能証明ではない
5回 PASS は再発防止の smoke としては有効ですが、performance non-regression や適切な timeout 値の統計的根拠にはなりません。
このリポジトリの #1538 でも、計測されていない phase や比較不能な変更については
no_claim/insufficient_dataとし、current-head の成功を性能非劣化の証拠へ読み替えない方針が定められています。PR 本文には次を明示すべきです。
推奨する最小実装
変更対象は
tests/hooks/codex-scope-rollup-capture.test.tsのみにします。この形なら、
elapsedMsが6.4秒か6.6秒かではなく、確認したい本来の契約を検証できます。elapsedMsを診断ログとして残す必要がある場合は、assertion には使わず、Date.now()より monotonic なperformance.now()を利用する方が適切です。Node.js のperformance.now()はプロセス開始を基準とした高分解能のミリ秒 timestamp です。(Node.js)Issue 本文の差し替え案
Goal
Outcome
In Scope
対象テストを
it.eachにより2ケースへ分割する。ケースごとに固定 reason code を検証する。
result.error === undefined、result.signal === null、result.status === 0を検証する。{"continue":true}、capture artifact 非生成、redaction を検証する。Vitest のケース timeout を outer adapter watchdog より大きい値にする。
focused test を5回連続実行する。
Out of Scope
production capture timeout
3,500msの変更grace
500msの変更fixture の sleep / exit behavior の変更
codex-hook-adapter.mjsの構造変更manifest flow / post-run verifier の高速化
他の
itブロックの timing assertionCI workflow の変更
performance non-regression の主張
Acceptance Criteria
AC1:
nonzero.pyとtimeout.pyがit.eachにより2件の独立した名前付きテストとして定義されている。AC2:
nonzero.pyはcapture_nonzero、timeout.pyはcapture_timeoutを生成する。AC3: 両ケースで
result.errorは未設定、result.signalはnull、result.statusは0である。AC4: 両ケースで stdout は exact
{"continue":true}、canonical.txtは0件、fixture canary と payload 本文は stderr に含まれない。AC5: 対象テストに
elapsedMsの上限 assertion が存在しない。AC6: focused transport test を5回連続実行し、全回 PASS する。
AC7: 対象ファイル全体、typecheck、lint、full test、build が PASS する。
AC8: PR evidence は
performance_claim: no_claimとし、各 focused run の command、exit code、対象ケース結果を記録する。Verification Commands
補助的な静的検査を残すなら、旧リテラルの存在確認ではなく次のようにします。
Allowed Paths
Stop Conditions
result.errorが outerspawnSynctimeout を示し、test-only watchdog の値変更が必要と判明した場合は、失敗時のerror.code、signal、elapsed、環境情報を記録して Issue の Scope Delta を更新する。capture phase と manifest/post-run phase の個別時間計測が必要になった場合は、production seam の抽出を別 Issue とする。
codex-postrun-verifier.mjsの Git subprocess timeout または artifact traversal bound が必要と判明した場合は、別 Issue とする。production の
3,500 / 500契約変更が必要になった場合は停止する。根本対応として別途検討すべき事項
今回の最小修正とは分離すべきですが、full-adapter latency を本当に管理するなら次の follow-up が必要です。
Follow-up 案
実装: Codex Stop adapter の capture / manifest / post-run phase timing と bounded subprocess contract を分離する対象候補:
実装内容:
runScopeRollupCapture()を production module として抽出する。capture result を文字列 stderr だけでなく構造化 status としてテスト可能にする。
capture、manifest producer、manifest write、post-run verifier の phase duration を分離する。
post-run verifier の各 Git subprocess に timeout を設定する。
artifacts/再帰走査に件数・深さ・時間の上限を設ける。test では注入可能な短い timeout/grace を使い、3.5秒を毎回実時間で待たずに state transition を検証する。
production timeout の変更を行う場合だけ、runner-identical な比較証跡を収集する。
最終結論
#1727 は「閾値を調整する Issue」ではなく、誤った計測対象を受け入れ条件から除去し、transport の意味論を直接検証する Issue に修正すべきです。
実装方針は次で固定するのが妥当です。
なお、current main の隔離ローカル実行は、今回の作業コンテナから GitHub への外向き名前解決ができず実施できませんでした。したがって、私は #1727 の flake を独立再現したとは主張しません。一方、AC/VC の逆転、存在しない Allowed Paths、計測範囲の不一致、branch assertion 不足は、現行ソースと Issue 契約から決定的に確認できる問題です。
# 敵対的レビュー — Issue #1727判定
REQUEST_CHANGES— 現状の Issue 契約のまま実装を開始すべきではありません。「不安定な wall-clock assertion を除去する」という目的は妥当です。しかし現行 AC1 は、
6500を6501、6999、60000のいずれかへ変更するだけでも達成できます。しかも対象のelapsedMsは capture transport 単体ではなく、adapter 起動、capture、manifest 生成、manifest 書き込み、post-run verifier の全処理時間です。この契約では原因を分離せず、別フェーズの遅延を大きな閾値で隠す false-green が成立します。技術的な系譜は次です。
PR #1699 では、OWNER の変更要求を受けて集約 timeout を撤去し、
it.eachによるケース分割へ修正されています。同 PR の実測では対象ファイルを3回連続実行して全回 PASS、最重量の transport 系ケースも約3.5~3.7秒でした。今回も同じ設計原則を適用すべきです。Blocker 1 — AC1 と Verification Command が false-green かつ逆向き
現行 AC1 は、要求しているのが「
6500から値が変わったこと」だけです。振る舞いではなくソース上の数値リテラルを受け入れ条件にしています。さらに AC1 の Verification Command は次です。
rg -n "toBeLessThan\\(6500\\)" tests/hooks/codex-scope-rollup-capture.test.tsこれは修正前には exit code 0、正しく assertion を削除した後には exit code 1 になります。つまり、通常の「コマンド成功を PASS とする」検証系では結果が逆です。AC2 も「5回連続」と記載しながら、Verification Commands には1回分しかありません。
リポジトリ自身のテスト方針も、「実装詳細ではなく入出力の振る舞いをアサーションする」と定めています。数値リテラルの変更確認は、この方針と一致しません。
必要な修正
AC1 は次のような behavior contract に変更すべきです。
nonzero.pyがcapture_nonzeroとして処理された。timeout.pyがcapture_timeoutとして処理された。{"continue":true}を返した。Blocker 2 — Allowed Paths が実在しない
Issue が許可している fixture パスは以下です。
しかし実際の配置は以下です。
adapter 自身も後者を fixture root として固定しています。
また、Out of Scope には adapter が
scripts/agent-hooks/配下にあり、「リトライ/バックオフロジック」を持つと書かれていますが、実体はscripts/session-recording/codex-hook-adapter.mjsです。対象の capture transport にリトライ/バックオフ処理はありません。このままでは、Issue が許可した fixture 修正を行おうとすると実在しないパスを編集することになり、実在パスを編集すると Stop Condition の「Allowed Paths 外」に該当します。唯一の Issue コメントも同じ誤ったパスを前提に overlap 判定しており、直接の技術的関連である #1527、#1534、#1693、#1699 を依存関係として扱っていません。
推奨
fixture の編集は今回不要です。Allowed Paths は次の1ファイルだけに狭めるべきです。
Blocker 3 —
elapsedMsは transport の時間を測っていないrunAdapter()の計時範囲は、外側の Node プロセスをspawnSync()で開始する直前から、そのプロセスが完全終了するまでです。timeout: 7000も capture producer ではなく、adapter プロセス全体に対するものです。一方、adapter の実際の流れは次です。
capture の timeout/nonzero は fail-open であり、その後に
runManifestFlow()が必ず実行されます。さらに post-run verifier は、対象リポジトリに対して以下を同期実行します。
git status --porcelain=v1 -z --untracked-files=allartifacts/以下の再帰走査git for-each-refgit config --get-regexp .これらには個別 timeout や走査件数上限がありません。dirty worktree、untracked file 数、
artifacts/の規模、Git の応答時間によって、capture transport と無関係にelapsedMsが増加します。したがって、現在の
は、次のどれが遅かったのかを区別できません。
Issue の名称と Goal は「transport fixture failure」ですが、実際の metric は full-adapter integration latency です。閾値だけを引き上げると、post-run verifier の性能劣化を transport のマージンとして吸収してしまいます。
Blocker 4 — 現在のテストは fixture 経路が実際に通ったことを証明していない
対象テストが検証しているのは以下だけです。
capture_nonzeroとcapture_timeoutのどちらも assertion していません。また、capture directory に.txtが作られていないことも確認していません。そのため、例えば以下の誤実装でも PASS し得ます。
timeout.pyが起動されず、別の早期 return を通った。capture_okと分類した。最低限、ケースごとに次の固定 diagnostic を要求する必要があります。
adapter は既にこの固定 reason code を出力する実装になっています。
Major 1 — 「恒常的 FAIL」という前提は証拠不足
Issue は「別コミット・別 worktree copy で3回すべて失敗した」と記載していますが、次の情報がありません。
result.elapsedMsresult.statusresult.signalresult.error?.codeartifacts/のファイル数spawnSynctimeout か一方、直前の PR #1699 では、同じテストファイルを3回連続実行して全回 PASSし、transport 系の最重量ケースは3.5~3.7秒と報告されています。
また、#1727 起票直前に current main へ入った PR #1723 のレビューでは、
testjob を含む required CI 全体が green と確認されています。さらに #1693 自身でも、変更を含む root worktree では失敗し、clean detached worktree では PASS したという環境依存の差が記録されています。
これは #1727 の再現報告が誤りだという意味ではありません。ただし、「すべての正規環境で恒常的に失敗する」と確定した証拠にはなっていません。より正確な Goal は次です。
Major 2 —
nonzeroとtimeoutを1件の test で集約すべきではない現在は、性質の異なる2経路を1件の
it内で順番に実行しています。nonzero.pyは即時の exit code 9、timeout.pyは30秒 sleep に対する内部 timeout を検証するものです。失敗原因、所要時間、期待 reason code が異なるため、独立した名前付きテストにすべきです。Vitest 公式も、同じテストを異なる入力で実行する用途として
test.each/it.eachを提供しています。(Vitest)これは #1693 / PR #1699 で既に採用された修正方針でもあります。
Major 3 — 三層 timeout の責務が混ざっている
現在の timeout は以下です。
spawnSyncitproduction capture の 3,500ms+500ms は policy に明記された契約です。
production Codex hook 自体は30秒です。
問題は、outer
spawnSyncと Vitest timeout を同じ7秒にしていることだけではありません。Node.js のspawnSync()は event loop をブロックし、timeout 後に kill signal を送っても、子プロセスが完全終了するまで戻らない仕様です。結果にはstatus、signal、timeout/failure 時のerrorが提供されます。(Node.js)したがって、Vitest timeout を
spawnSyncの外側に置いただけでは、独立した hard-kill boundary になりません。これは Node の同期ブロッキング仕様から導かれる推論です。Vitest の Node 環境における既定 test timeout は5,000msですが、同期 call のプロセスツリー終了を保証する仕組みではありません。(Vitest)今回の最小修正では
3,500 / 500は変更しない。elapsedMsを semantic assertion から外す。result.error、result.signal、result.statusを検証する。result.error.codeが timeout を示した証拠がある場合だけ行う。という順序が妥当です。
Major 4 — fixture の遅延時間を変更すべきではない
timeout.pyは意図的に30秒 sleep しています。production capture timeout 3.5秒を十分に超え、必ず timeout 経路へ入れるための fixture です。これを5秒や6秒へ短縮しても full-adapter の不安定性は解決しません。むしろ、将来 production timeout が変更された際に fixture が timeout 経路へ入らなくなる境界リスクを増やします。
nonzero.pyも stdout/stderr へ明示的な canary を書き、exit code 9 で終了する redaction fixture です。内容を変更する必要はありません。したがって今回の Allowed Paths から両 fixture を外すべきです。
Major 5 — 5回連続実行は stability smoke であり、性能証明ではない
5回 PASS は再発防止の smoke としては有効ですが、performance non-regression や適切な timeout 値の統計的根拠にはなりません。
このリポジトリの #1538 でも、計測されていない phase や比較不能な変更については
no_claim/insufficient_dataとし、current-head の成功を性能非劣化の証拠へ読み替えない方針が定められています。PR 本文には次を明示すべきです。
推奨する最小実装
変更対象は
tests/hooks/codex-scope-rollup-capture.test.tsのみにします。この形なら、
elapsedMsが6.4秒か6.6秒かではなく、確認したい本来の契約を検証できます。elapsedMsを診断ログとして残す必要がある場合は、assertion には使わず、Date.now()より monotonic なperformance.now()を利用する方が適切です。Node.js のperformance.now()はプロセス開始を基準とした高分解能のミリ秒 timestamp です。(Node.js)Issue 本文の差し替え案
Goal
Outcome
In Scope
it.eachにより2ケースへ分割する。result.error === undefined、result.signal === null、result.status === 0を検証する。{"continue":true}、capture artifact 非生成、redaction を検証する。Out of Scope
3,500msの変更500msの変更codex-hook-adapter.mjsの構造変更itブロックの timing assertionAcceptance Criteria
nonzero.pyとtimeout.pyがit.eachにより2件の独立した名前付きテストとして定義されている。nonzero.pyはcapture_nonzero、timeout.pyはcapture_timeoutを生成する。result.errorは未設定、result.signalはnull、result.statusは0である。{"continue":true}、canonical.txtは0件、fixture canary と payload 本文は stderr に含まれない。elapsedMsの上限 assertion が存在しない。performance_claim: no_claimとし、各 focused run の command、exit code、対象ケース結果を記録する。Verification Commands
補助的な静的検査を残すなら、旧リテラルの存在確認ではなく次のようにします。
Allowed Paths
Stop Conditions
result.errorが outerspawnSynctimeout を示し、test-only watchdog の値変更が必要と判明した場合は、失敗時のerror.code、signal、elapsed、環境情報を記録して Issue の Scope Delta を更新する。codex-postrun-verifier.mjsの Git subprocess timeout または artifact traversal bound が必要と判明した場合は、別 Issue とする。3,500 / 500契約変更が必要になった場合は停止する。根本対応として別途検討すべき事項
今回の最小修正とは分離すべきですが、full-adapter latency を本当に管理するなら次の follow-up が必要です。
Follow-up 案
実装: Codex Stop adapter の capture / manifest / post-run phase timing と bounded subprocess contract を分離する対象候補:
実装内容:
runScopeRollupCapture()を production module として抽出する。artifacts/再帰走査に件数・深さ・時間の上限を設ける。最終結論
#1727 は「閾値を調整する Issue」ではなく、誤った計測対象を受け入れ条件から除去し、transport の意味論を直接検証する Issue に修正すべきです。
実装方針は次で固定するのが妥当です。
なお、current main の隔離ローカル実行は、今回の作業コンテナから GitHub への外向き名前解決ができず実施できませんでした。したがって、私は #1727 の flake を独立再現したとは主張しません。一方、AC/VC の逆転、存在しない Allowed Paths、計測範囲の不一致、branch assertion 不足は、現行ソースと Issue 契約から決定的に確認できる問題です。
squne121 commentedon Jul 25, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 25, 2026
Contract Review Result
squne121 commentedon Jul 25, 2026
Contract Review Result
squne121 commentedon Jul 25, 2026
implement-issue: 実装完了 (2026-07-25T06:21:46Z)
.claude/worktrees/issue-1727-codex-scope-rollup-capture-test-ts-transworktree-issue-1727-codex-scope-rollup-capture-test-ts-trans-t "transport fixture")5回連続実行: 5/5 exit code 0 / 2 tests passed(performance_claim: no_claim, stability smoke)proceed_with_collision_evidence(実装: playtest-log の JSON Schema / validator の追加 #420, 実装: visual diff AI/VLM triage を非ブロッキング助言として分離する #1390 は構造的に disjoint)squne121 commentedon Jul 25, 2026
impl-review-loop 完了
tests/hooks/codex-scope-rollup-capture.test.ts)、Allowed Paths gate: okPR は Draft のままです。マージは人間判断でお願いします。
squne121 commentedon Jul 25, 2026
PR #1741 に対する REQUEST_CHANGES レビューの fix_delta 対応を実施した。
対応内容
[codex-hook-adapter] warn: scope-rollup capture skipped (<reason>))に基づく1行 exact match へ変更した。payloadText(payload)全文一致チェックを、複数の高識別性 fragment(schema marker /invocation_id/generated_at)ごとの stderr・stdout 両方への非漏洩チェックへ強化した。fixture canary チェックがtimeout.pyでは vacuous である旨(fixture は変更せず)を PR 本文・テストコードのコメント双方に明記した。-t "transport fixture")を5回連続実行し、raw verbose ログ全文・各回の exit code・head SHA・node/pnpm バージョンを記録した。全5回とも exit code 0・2 tests passed。ログの sha256:sha256:9b95ee0ca62ee9c929e9c13e2d24a1cc8d3b8ae0c8374c550fd0d198cb155942。10000ms へ引き上げ、コメントを正確な表現に修正した。toEqual([]))へ強化した。fixture(
tests/fixtures/hooks/scope-rollup-capture/**)は Out of Scope のため一切変更していない。変更ファイルはtests/hooks/codex-scope-rollup-capture.test.tsの1件のみ(Allowed Paths と一致、gh pr diff 1741 --name-onlyで確認済み)。検証
pnpm typecheck/pnpm lint/pnpm test(1727 tests / 100 files 全成功)/pnpm build/uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py(21件成功)すべて PASS。PR 状態
aa66c2199723b5eb8f70c06e67aef98b477724abBLOCKED(レビュー承認待ち。conflict は無し、mergeable: MERGEABLE)PUT .../pulls/1741/update-branch(merge_only)で BEHIND から base main へ追従済み。squne121 commentedon Jul 25, 2026
impl-review-loop 完了(fix_delta 反映後)
外部レビュー(issuecomment-5077436821)が指摘した false-green 懸念(P1-1〜P1-3、P2-1〜P2-2)をすべて修正済み。
tests/fixtures/hooks/scope-rollup-capture/*.py)は Out of Scope のため一切変更なし。Allowed Paths gate: ok(変更ファイルは対象テストファイル1件のみ)toEqual)に変更、payload の複数fragment非漏洩検証、5回連続実行の監査証跡(sha256付き)追記、Vitest timeout説明の是正、capture directory完全空チェックへ強化を、test-runner・pr-reviewer が独立に diff・実行結果で確認済み。PR は Draft のままです。マージは人間の判断でお願いします。
test: split transport fixture failure test via it.each (#1727) (#1741)