Skip to content

refactor: テスト基盤の fixture 集約 — render/flip/repo-copy/fake-status を test-lib.sh へ (PR-2/4, Refs #189) - #191

Merged
kosako merged 1 commit into
mainfrom
refactor-test-fixtures-189
Jul 10, 2026
Merged

refactor: テスト基盤の fixture 集約 — render/flip/repo-copy/fake-status を test-lib.sh へ (PR-2/4, Refs #189)#191
kosako merged 1 commit into
mainfrom
refactor-test-fixtures-189

Conversation

@kosako

@kosako kosako commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Refs #189(全体リファクタリング・挙動不変)の PR-2/4。ultracode 監査の CONFIRMED 所見のうちテスト基盤系 4 件を実施する。テストの assert 対象・出力・exit code は不変。

変更内容

  1. render_personal_into SOURCE_DIR ROOT を test-lib.sh へ集約(6 本に複製されていた throwaway chezmoi apply ヘルパ)
  2. make_flipped_source / flip_personal_capability を追加し、「source 丸ごと copy + .git 除去 + personal 限定 capability flip」fixture ×9 を置換
    • yqenv(V) 代入が現行リテラル式と profiles.yaml byte-identical であることは監査の検証フェーズで実測済み(true / false / 複合 flip の 3 ケース)。boolean 専用と明記。all-profile 版 set_capability_all とは統合しない(fail-closed guard 込みの別契約で、test-policy.sh がその契約自体を pin している)。
  3. copy_repo_fixture DEST を追加し、「scripts + .chezmoidata/*.yaml の最小 repo copy」fixture ×8 を置換(機械置換でちょうど 8 hit を確認)。test-policy の make_fixture は名前・グローバル変数・cleanup 登録の契約を維持した thin wrapper に。
  4. test-doctor.sh の root-pinning 契約付き fake status.sh ×2 を write_root_pinned_status_sh DEST JSON に集約(payload は逐語移送・printf '%s\n' で quoted heredoc 内へ挿入・agent-tools の health 監視(doctor ↔ status.sh)を実運用で有効化する #73/agent-tools の presence/health を report-only で表示する check を追加する #71 の regression 説明は helper と call site のコメントに保持)

挙動不変の検証(実施済み)

  • bash -n / shellcheck -S warning: 完全 clean
  • 全テスト suite green(16 本)
  • 旧新出力の byte 比較: 影響 8 suite(claude/codex/git-signing/ssh/npmrc/doctor/preflight/policy)を main worktree と本 branch で実行し、rc + stdout + stderr が yq WARN 行のタイムスタンプ正規化後に全 suite byte-identical
  • leak 修正の実証: 新コードは 1 実行で TMPDIR への render root 追加ゼロ / 旧コード(main)は同一実行で render root が残留することを実測
  • render 出力: scripts/ のみの変更で managed target に構造的に無関係(baseline diff も PR-1 で確立済みの手順で確認)

レビュー観点(お願いしたいこと)

  • caller-creates-root への書き換え 3 ファイルで、root の生存期間(後続 assert が $home 等を参照)が EXIT まで維持されているか
  • flip_personal_capability の yq 式(env(V))が boolean flip でリテラル式と等価であること
  • write_root_pinned_status_sh が生成する status.sh の実行意味(exit 1/3・ran-marker・JSON 1 行)が旧 heredoc と同一か
  • fixture 置換(×8 / ×9)の取りこぼし・過剰置換がないか

🤖 Generated with Claude Code

https://claude.ai/code/session_016qw8BkUDu5WdwhYfiFFX5n

…t-lib.sh へ (Refs #189)

ultracode 監査の CONFIRMED 所見 4 件 (test-infra 系) を実施。テストの
assert 対象・出力・exit code は不変 (検証は PR 本文)。

- render_personal_into を test-lib.sh へ集約 (6 本に複製されていた
  throwaway chezmoi apply ヘルパ)。caller-creates-root 契約 (#150) に
  統一したことで、claude/codex/git-signing の 3 本に残っていた
  command-substitution 起因の render root leak も解消 (helper 内の
  tmp_roots+= がサブシェルに閉じ cleanup trap から漏れていた)
- make_flipped_source / flip_personal_capability を追加し「source copy +
  .git 除去 + personal capability flip」fixture x9 を置換 (yq の
  env(V) 代入はリテラル式と byte-identical を検証済み。boolean 専用と
  明記。all-profile 版 set_capability_all とは契約が違うため統合しない)
- copy_repo_fixture を追加し「scripts + .chezmoidata/*.yaml の最小 repo
  copy」fixture x8 を置換 (test-doctor 6 / test-preflight 1 /
  test-policy make_fixture は thin wrapper 化)
- test-doctor.sh 内で 2 回逐語複製されていた root-pinning 契約付き fake
  status.sh を write_root_pinned_status_sh に集約 (JSON payload は逐語
  移送・生成される status.sh の実行意味は不変)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016qw8BkUDu5WdwhYfiFFX5n
@kosako

kosako commented Jul 10, 2026

Copy link
Copy Markdown
Owner Author

Codex 相互レビュー結果(author=Claude → reviewer=Codex)

codex exec(gpt-5.6-sol, read-only, reasoning=medium)によるレビュー。

判定: ✅ merge 可(must 0 件) — should 0 / nit 0

重点観点の検証結果(Codex 出力より):

  • caller-creates-root: 3 ファイルとも render root を親シェルで tmp_roots に登録し、後続 assert 完了後の EXIT trap まで維持
  • flip_personal_capability: 実環境の yq で env(V) の true / false がともに !!bool になることを確認
  • write_root_pinned_status_sh: exit 1/3・root pinning・ran-marker・JSON 1 行+改行・shebang・chmod +x は旧 heredoc と同じ実行意味
  • fixture 置換: 取りこぼし・過剰置換・helper の command substitution 内呼び出しなし
  • test-ssh.sh のパス変更: assert が参照する $off_root/home/.ssh/config に影響なし
  • テスト契約(assert 対象・文言・exit code): 差分上で観測可能な変更なし

author 側検証: 全 16 suite green / 影響 8 suite の旧新出力(rc+stdout+stderr)が timestamp 正規化後 byte-identical / render-root leak 修正を実測(新=追加ゼロ・旧=残留)。

@kosako
kosako merged commit 7eb646c into main Jul 10, 2026
2 checks passed
@kosako
kosako deleted the refactor-test-fixtures-189 branch July 10, 2026 23:17
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.

1 participant