Skip to content

chore(#559): add afterAll cleanup for temp fixtures in manifest-check tests - #562

Merged
squne121 merged 1 commit into
mainfrom
worktree-issue-559-agent-session-manifest-check-temp-fixtur
Jun 2, 2026
Merged

squne121 merged 1 commit into
mainfrom
worktree-issue-559-agent-session-manifest-check-temp-fixtur

Conversation

@squne121

@squne121 squne121 commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • cleanupTempFixtures() helper を追加し、beforeAll / afterAll の両方から呼ぶ
  • rmSync(path, { force: true }) で idempotent cleanup を実装
  • temp-unsupported.txt / temp-invalid-no-markers.md をテスト終了後に削除

Closes #559

Contract Snapshot: #559 (comment)

Verification

Check Result
typecheck pass
lint pass
test (313 passed, 0 failed) pass
build pass
AC2: temp-unsupported.txt absent after test pass
AC3: temp-invalid-no-markers.md absent after test pass

allowed_paths_compliance: true

🤖 Generated with Claude Code

… tests

Adds cleanupTempFixtures() helper called in both beforeAll and afterAll,
ensuring temp-unsupported.txt and temp-invalid-no-markers.md are removed
after test runs to keep the working tree clean.

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

squne121 commented Jun 2, 2026

Copy link
Copy Markdown
Owner Author
TEST_VERDICT:
  result: PASS
  mergeable: MERGEABLE
  merge_state_status: BLOCKED
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 5
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

検証結果レポート

Issue #559: agent-session-manifest テスト後処理 cleanup

AC 確認コマンド 実行結果(要約) exit code 判定
AC1 rg -n 'afterAll|afterEach|onTestFinished|beforeAll' tests/agent-session-manifest-check.test.ts afterAll 検出、rmSync import ・ 呼び出し確認 0 PASS
AC2 pnpm test -- tests/agent-session-manifest-check.test.ts && test ! -f temp-unsupported.txt 16 test files passed, 313 tests passed 0 PASS
AC3 test ! -f temp-invalid-no-markers.md ファイルが存在しない 0 PASS
AC4 rg -n 'unsupported file type|no supported manifest files|marker' assertion 文字列が 7 箇所で検出される 0 PASS
AC5 pnpm test && pnpm typecheck && pnpm lint && pnpm build test: 313 passed, typecheck: OK, lint: OK, build: OK 0 PASS

総合判定

  • 全 AC PASS: YES
  • FAIL した AC: なし
  • SKIP した AC: なし
  • human_review_required: NO

Notes

  • PR mergeability: mergeable=MERGEABLE ですが merge_state_status=BLOCKED (required status checks 待ち)
  • afterAll フック内で rmSync により temp fixture を確実にクリーンアップする実装が確認できました
  • テスト実行後、temp-unsupported.txt と temp-invalid-no-markers.md が存在しないことを確認
  • 既存の assertion 文字列(unsupported file type / no supported manifest files / marker)がすべて保持されています

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, mergeStateStatus=CLEAN

Evidence Check

  • AC coverage: 5/5 confirmed via TEST_VERDICT_MACHINE (AC1-AC5 all PASS, verification_skipped_count: 0)
  • Allowed Paths: compliant (only tests/agent-session-manifest-check.test.ts modified)
  • CI Verification: all 7 checks pass (build, e2e, lint, python-test, test, typecheck, validate-generated-artifact) on head SHA 6064d33
  • 検証コマンド結果: TEST_VERDICT_MACHINE v1 コメントで全 AC PASS 確認済み。verification_commands_pass: 5, verification_commands_fail: 0, verification_skipped_count: 0

Blockers

  • なし

Non-blockers

  • なし

LOOP_VERDICT

verdict: APPROVE
blockers: []
mergeable: MERGEABLE
mergeStateStatus: CLEAN
reviewed_head_sha: 6064d33e8a68038df34fd8009dfceb2590a7d70b
recommendations: []
follow_up_issue_requests: []

@squne121

squne121 commented Jun 2, 2026

Copy link
Copy Markdown
Owner Author

結論: APPROVE寄り / Blockerなし

PR #562 は、Issue #559 の契約に対して 実装としては十分に合格です。変更は tests/agent-session-manifest-check.test.ts 1ファイルのみで、Issue #559 の Allowed Paths と一致しています。PR 差分も cleanupTempFixtures()、beforeAll、afterAll、rmSync(path, { force: true }) の追加に限定され、Issue が指定した preferred implementation と整合します。([GitHub]1)

契約充足の確認

Issue #559 は、temp-unsupported.txt / temp-invalid-no-markers.md をテスト終了後に残さないこと、原則として repo fixture 配下の既知 temp path を beforeAll + afterAll で rmSync(path, { force: true }) cleanup することを要求しています。([GitHub]2)

PR #562 の差分は、対象 temp path 配列を追加し、cleanupTempFixtures() で両ファイルを rmSync(p, { force: true }) し、beforeAll と afterAll の両方から呼んでいます。既存 assertion 文字列を変えていない点も AC4 と整合します。([GitHub]1)

Vitest 公式ドキュメント上、beforeAll は suite の test 実行前に1回、afterAll は suite 完了後に1回実行されます。したがって、今回の「開始時に stale artifact を消す」「終了時に生成 artifact を消す」という使い方は lifecycle hook の仕様に合っています。([Vitest]3)

Node.js 公式ドキュメント上、fs.rmSync(path, { force: true }) は path が存在しない場合の例外を無視します。既知の file path を idempotent に消す今回の用途には適切です。([Node.js]4)

敵対的レビュー結果

Blocker 1: なし

コード上の主要リスクは見つかりません。afterAll cleanup はテスト失敗時にも通常実行される lifecycle に乗っており、beforeAll cleanup により前回実行で残った stale artifact も次回実行開始時に除去できます。PR の検証コメントでは typecheck / lint / test / build が pass、AC2/AC3 の対象ファイル不在も確認済みとされています。([GitHub]5)

Non-blocker 1: TEST_VERDICT の machine-readable runtime 証跡が弱い

PR コメントの TEST_VERDICT は verification_commands_pass: 5 としつつ、runtime_ac_results: [] になっています。一方で、本文テーブルには AC2/AC3 の runtime 的なファイル存在確認が記載されています。([GitHub]5)

これは実装の欠陥ではありませんが、将来 gate が runtime_ac_results を機械判定するなら blind spot になります。PR #555 では runtime_ac_results に AC2/AC3/AC6/AC7 の command・exit_code・status が構造化されていたため、同じ様式に寄せた方が reviewer / gate の品質は上がります。([GitHub]6)

推奨修正は PR 本体ではなく、verdict 生成側の follow-up です。

follow_up_issue:
  title: "TEST_VERDICT の runtime AC 結果を machine-readable に正規化する"
  rationale: "PR #562 では runtime 的な AC2/AC3 の証跡が本文表にはあるが runtime_ac_results が空で、gate が構造化結果を読む場合に検出不能になる"
  scope:
    - "runtime_only / file-existence AC の command, exit_code, status を runtime_ac_results に出す"
    - "本文表と machine-readable verdict の drift を禁止する"

Non-blocker 2: beforeAll の stale artifact 除去を直接検証するコマンドが不足

Issue #559 は、書き込み先を変えるだけでは stale repo-local artifact が残るため、legacy path の cleanup を必須にしています。([GitHub]2)

PR 実装自体は beforeAll でも cleanup しているため問題ありません。ただし、検証コマンドは rm -f してから test を実行する形なので、「事前に stale artifact が存在していた場合に beforeAll で消える」ことを直接証明していません。([GitHub]2)

高品質化するなら、追加で次のような verification を comment に残すとよいです。

printf 'stale\n' > tests/fixtures/agent-session-manifest/temp-unsupported.txt
printf 'stale\n' > tests/fixtures/agent-session-manifest/temp-invalid-no-markers.md
pnpm test -- tests/agent-session-manifest-check.test.ts -t 'valid JSON manifest fixture'
test ! -f tests/fixtures/agent-session-manifest/temp-unsupported.txt
test ! -f tests/fixtures/agent-session-manifest/temp-invalid-no-markers.md

このコマンドは、temp fixture を生成しない filtered test でも beforeAll が stale artifact を消すことを確認できます。

Non-blocker 3: 異常終了時の artifact 残存は未解決だが、Issue scope 外

afterAll は通常の test lifecycle では妥当ですが、プロセス kill、runner crash、OS 側の強制終了では cleanup は保証できません。これは Vitest hook の問題ではなく、任意の in-process teardown に共通する限界です。Issue #559 は「通常の pnpm test 実行後に untracked artifact を残さない」契約なので、今回の PR では block しません。([GitHub]2)

本質的にさらに強くするなら、repo-local fixture への書き込みをやめて per-test temp dir を使う設計が上位改善です。ただし Issue #559 は当該1ファイル限定で、他テストファイルや広範な test-hygiene 改修を Out of Scope としているため、この PR で要求すべきではありません。([GitHub]2)

関連Issue / PRとの整合

Issue #559 は PR #555 の post-merge cleanup 観察由来の follow-up と明記されており、PR #555 側の主題である GitHub Actions Node24 対応とは分離された test-hygiene 改善です。今回の PR #562 はその派生原因である repo-local temp artifact のみを処理しており、スコープ分離は妥当です。([GitHub]2)

また、元の agent-session-manifest-check.test.ts は Issue #378 の manifest check gate 用 test suite に由来しますが、PR #562 は validator / extractor / schema / CI gate の semantics には触れていません。Issue #378 の Out of Scope にある validator / extractor / schema 変更にも抵触していません。([GitHub]7)

推奨コメント案

## Verdict: APPROVE

Blocker はありません。

PR #562 は Issue #559 の契約に沿って、`tests/agent-session-manifest-check.test.ts` の既知 temp fixture path
`temp-unsupported.txt` / `temp-invalid-no-markers.md` を `cleanupTempFixtures()` に集約し、
`beforeAll` / `afterAll` の両方から `rmSync(path, { force: true })` で削除しています。

Vitest の lifecycle 上、`beforeAll` は suite 実行前、`afterAll` は suite 完了後に1回実行されるため、
通常の `pnpm test` 実行後に repo-local untracked artifact を残さない目的に合っています。
Node `fs.rmSync(..., { force: true })` も、path 不在時に例外を出さない idempotent cleanup として適切です。

Non-blocker:
- TEST_VERDICT の `runtime_ac_results: []` は弱いです。AC2/AC3 の file-existence check を本文表だけでなく machine-readable に出す follow-up を推奨します。
- stale artifact が事前に存在する場合の `beforeAll` cleanup を直接証明する追加 verification があると、証跡品質が上がります。

追加確認例:
```bash
printf 'stale\n' > tests/fixtures/agent-session-manifest/temp-unsupported.txt
printf 'stale\n' > tests/fixtures/agent-session-manifest/temp-invalid-no-markers.md
pnpm test -- tests/agent-session-manifest-check.test.ts -t 'valid JSON manifest fixture'
test ! -f tests/fixtures/agent-session-manifest/temp-unsupported.txt
test ! -f tests/fixtures/agent-session-manifest/temp-invalid-no-markers.md

上記は品質改善であり、現 PR の merge blocker ではありません。



::contentReference[oaicite:14]{index=14}

@squne121
squne121 merged commit 7ab216a into main Jun 2, 2026
7 checks passed
@squne121
squne121 deleted the worktree-issue-559-agent-session-manifest-check-temp-fixtur branch June 2, 2026 02:41
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.

実装: agent-session-manifest-check テストが生成する temp fixture を afterAll で後始末する

1 participant