Skip to content

実装: E2E / browser playtest foundation を導入し、movement + projectile の実ブラウザ検証導線を作る #447

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1"
goal_ref: "PR #444 で deferred された『ブラウザ上での実際の弾道・pointer 体感確認』を、後続 playtest issue で実行可能にするため、E2E / browser playtest foundation を導入する"
change_kind: test-infra

Parent Issue

#1

Parent Goal Ref

  • Goal: 自機移動と Projectile 射撃システムを、Canvas 上で実際に操作・確認できる状態にする
  • Deferred source: PR feat(#1): 自機移動と Projectile 射撃システム (AC1-AC22) #444 Runtime Verification Applicability
    • decision: deferred
    • deferred_destination: phase / M1 Foundation Gate playtest
    • ブラウザ上での実際の弾道・pointer 体感確認は後続 playtest issue で実施

Source

Current Validated Scope

  • Playwright Test の導入(@playwright/test devDependency 追加、playwright.config.ts、pnpm test:e2e script)
  • tests/e2e/ 配下に movement + projectile smoke test を追加
  • Canvas / state 観測の最小設計(import.meta.env.DEV または test-only hook で production behavior 非影響)
  • docs/product/playtest-log.md への記録導線整備(最小テンプレ追加)
  • 既存 CI への pnpm test:e2e 統合(必須)

Remaining Parent Gaps

  • ブラウザ上での実弾道・pointer 体感の確認手段(本 Issue で foundation 整備、別 execution issue で実 playtest 実施)

Problem

PR #444 では unit test / build は通っているが、実ブラウザ上で以下を確認する基盤が未整備:

  • WASD 入力が実ブラウザで player movement に接続されているか
  • pointer down / move / up / cancel / lostpointercapture が実ブラウザで破綻しないか
  • projectile が Canvas 上で視認できるか
  • fixed timestep / render / input binding / Canvas の統合がブラウザ環境で成立するか
  • 人間による体感確認結果を playtest-log に残す導線

既存 docs/product/playtest-protocol.md は browser_automation を UI/Canvas/DOM 統合・リグレッションの根拠として認めているが、現状の package scripts には test:e2e 相当の入口がない。

Outcome

Playwright ベースの最小 E2E foundation が導入され、PR #444 相当の movement + projectile を対象に以下が可能になっている:

  • pnpm test:e2e でローカル / CI から実ブラウザ smoke test を実行できる
  • pnpm test:e2e:ui または pnpm test:e2e:debug で人間が操作確認しやすい導線がある
  • Canvas / input / projectile の最低限の統合テストが存在する
  • failure 時に trace(少なくとも trace)が保存される
  • docs/product/playtest-log.md の schema に従って、PR feat(#1): 自機移動と Projectile 射撃システム (AC1-AC22) #444 の deferred runtime verification を記録できる最小サンプルまたは手順がある

In Scope

  • @playwright/test devDependency と playwright.config.ts 追加
  • pnpm test:e2e / pnpm test:e2e:ui / pnpm test:e2e:debug / pnpm test:e2e:headed / pnpm playwright:install / pnpm playwright:install:ci scripts
  • tests/e2e/ smoke test(Playwright webServer は Vite preview(pnpm build && pnpm preview)を使用、Canvas 存在、表示サイズ、W/A/S/D 入力、pointer down/move/up による射撃、projectile 観測の最小手段)
  • Canvas / state 観測の最小境界(read-only observability hook、e2e 専用フラグで gate、production build に含まれない)
  • Playtest 記録導線(docs/product/playtest-protocol.md の browser_automation / human_internal 使い分けに沿う。最小テンプレ or docs/product/playtest-sessions/README.md)
  • CI 統合(既存 CI に pnpm test:e2e 追加、browser install + failure 時 artifact upload を必須とする)

Out of Scope

  • 敵、当たり判定、ダメージ、sortie 終了条件の実装
  • balance / tuning の決定
  • 「面白さ」「操作感が良い」など UX 妥当性を自動 E2E の結果だけで主張すること
  • 外部テスター募集
  • raw video / PII を public repository に保存
  • 大規模 telemetry 基盤
  • Vitest Browser Mode への全面移行
  • visual regression snapshot の厳密な baseline 運用
  • docs/product/playtest-log.md の schema または UX evidence policy の変更(設計: MVP 自動プレイテスト用の最小 telemetry / event log contract を定義する #419 の責務)
  • Playwright CLI 専用 Claude agent skill / .claude/agents/ 変更(別 Issue)
  • Vite dev server(vite dev)を E2E webServer として使用すること(preview を使う)

Implementation Gate

PR #444(feat(#1): 自機移動と Projectile 射撃システム)はマージ済み(commit 906533e)。
movement + projectile の runtime code は既に main に存在するため、#447 は即時実装可能。

Acceptance Criteria

  • AC1: package.json に test:e2e script が追加されている
  • AC2: @playwright/test が devDependency として追加されている
  • AC3: playwright.config.ts が存在し、Vite app を起動して E2E test を実行できる
  • AC4: tests/e2e/ 配下に movement + projectile smoke test が存在する
  • AC5: E2E smoke test は実ブラウザで以下をすべて検証する:
    • Playwright webServer 経由でアプリが起動する
    • canvas が表示され、非ゼロの CSS サイズを持つ
    • KeyW/KeyA/KeyS/KeyD 押下で player position が期待する軸に変化する
    • keyup で移動入力が止まる
    • canvas 上で pointer/mouse down によって projectile が少なくとも 1 つ生成される
    • simulation 進行後に projectile の count または position が変化する
    • pointerup で primary fire 入力が止まる
    • pointercancel または lostpointercapture で active pointer state がクリアされる
  • AC6: failure 時に必ず trace が保存される設定になっている(trace: "retain-on-failure" 使用、または retries: 1 + trace: "on-first-retry" の組み合わせを明記)
  • AC7: pnpm test:e2e がローカルで PASS する
  • AC8: pnpm typecheck && pnpm lint && pnpm test && pnpm build が PASS する
  • AC9: playtest-log への記録方法が docs/product/playtest-log.md の schema と矛盾しない
  • AC10: 自動 E2E の結果を UX 妥当性の証拠として扱わない旨が docs または PR body に明記されている
  • AC11: E2E tests はファイル存在・文字列 grep だけでなく behavioral assertions を含む
  • AC12: test-only observability hook は read-only であり、e2e 専用フラグで gate され、通常の production build 出力に含まれない(pnpm build 結果に __LOOP_E2E__ が存在しない)
  • AC13: CI 上で Playwright browser が install され、failure 時の artifact(report / trace)が upload される
  • AC14: docs/product/playtest-log.md の schema または UX evidence policy を本 Issue では変更しない

Verification Commands

# AC1
$ node -e "const p=require('./package.json'); if (!p.scripts || !p.scripts['test:e2e']) process.exit(1)"

# AC2
$ node -e "const p=require('./package.json'); if (!p.devDependencies || !p.devDependencies['@playwright/test']) process.exit(1)"

# AC3
$ test -f playwright.config.ts

# AC4
$ test -d tests/e2e
# preflight-scope: runtime_only
$ rg -n "projectile|pointer|keyboard|canvas|WASD|KeyW|mouse" tests/e2e

# AC5
# preflight-scope: runtime_only
$ pnpm test:e2e
# preflight-scope: runtime_only
$ pnpm test:e2e -- --project=chromium --reporter=list

# AC6
# preflight-scope: runtime_only
$ rg -n "retain-on-failure|on-first-retry" playwright.config.ts

# AC7
# preflight-scope: runtime_only
$ pnpm test:e2e

# AC8
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build

# AC9
# preflight-scope: pr_review_only
$ rg -n "browser_automation|human_internal" docs/product/playtest-log.md docs/product/playtest-protocol.md
$ test -d docs/product/playtest-sessions

# AC10
# preflight-scope: runtime_only
$ rg -n "UX|妥当性|browser_automation|human_internal" docs/product playwright.config.ts

# AC11
# preflight-scope: runtime_only
$ rg -n "expect\|toBeVisible\|toHaveCSS\|waitFor\|toBe\|toContain" tests/e2e

# AC12 (production build に hook が漏れないこと)
$ pnpm build
$ ! rg "__LOOP_E2E__|LOOP_E2E" dist

# AC13 (CI の browser install と artifact upload)
$ rg -n "playwright install\|playwright-report\|test-results" .github/workflows

# AC14 (playtest-log schema 変更なし)
# preflight-scope: pr_review_only
$ git diff main -- docs/product/playtest-log.md | grep "^+" | grep -v "^+++" | wc -l

Allowed Paths

  • package.json
  • pnpm-lock.yaml
  • playwright.config.ts
  • tests/e2e/**
  • .github/workflows/**
  • docs/product/playtest-log.md
  • docs/product/playtest-protocol.md
  • docs/product/playtest-sessions/**
  • src/**(test-only observability hook に必要な最小変更のみ、production behavior 非影響)

Product Spec Context

  • diff_rationale: "E2E playtest foundation の記録導線として docs/product/playtest-sessions/ ディレクトリと最小サンプルを追加するのみ。docs/product/playtest-log.md スキーマおよび UX evidence policy は変更しない(AC14 で明示)。"
  • changed_requirement_id: not_applicable(既存スキーマの変更なし)
  • affected_sections: not_applicable(additive のみ)
  • spec_change_kind: additive_sample_only(既存スキーマへの追加に限定)

Runtime Verification Applicability

decision: immediate
reason: >
  この Issue は runtime code の主要挙動を変更しないが、実ブラウザ上の input / Canvas / render 統合を
  検証する基盤を導入するため、`pnpm test:e2e` による browser_automation runtime verification を必須とする。
deferred_destination: null
deferred_verification_condition: null
applicable_acs:
  - AC5
  - AC7
runtime_environment:
  tools:
    - playwright: "@playwright/test (project-local CLI)"
    - browser: "Chromium (installed via pnpm exec playwright install chromium)"
    - node: "Node.js 22 (pnpm)"
  auth: none
  network: "Vite preview server (localhost:4173, no external network)"
  setup_command: "pnpm exec playwright install chromium"
skip_condition: >
  If Playwright browsers are not installed and `pnpm exec playwright install chromium` fails,
  exit with code 77 (SKIP). Do NOT treat as PASS. Record skip reason in PR body.
fallback_exclusion: >
  A test run that passes only because assertions are absent or trivially skipped is NOT PASS.
  `pnpm test:e2e` must pass with all behavioral assertions in AC5 executed against real browser.
evidence_requirements:
  artifacts:
    - path: "playwright-report/"
      description: "HTML test report (generated by `pnpm test:e2e`)"
    - path: "test-results/"
      description: "trace files on failure (retain-on-failure or on-first-retry)"
  pr_body_must_include: "pnpm test:e2e output (pass/fail count) and trace artifact link on failure"

Stop Conditions

  • production behavior を変えないと E2E 観測が成立しない場合
  • Canvas 描画の pixel-perfect visual regression を必須にしないと AC 達成できない場合
  • Playwright ではなく別ツールへ全面移行する必要が判明した場合
  • CI 実行時間 / browser install / 環境依存で既存 CI を不安定化させる場合
  • docs/product/playtest-protocol.md の UX evidence policy と矛盾する場合
  • 外部テスター / 録画 / PII 保存が必要になる場合

Required Skills

  • Playwright Test(fixtures, locators, page.keyboard, page.mouse, trace)
  • Vite dev/preview server を test runner から起動する手順
  • TypeScript(strict mode)
  • GitHub Actions(CI 統合)

Delivery Rule

  • 1 Issue = 1 PR
  • Draft PR で開始し、AC 全件 PASS 後に Ready for Review

Activity

  1. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    人間からのコメントです。
    開発環境にplaywright や playwright CLI(?)やplaywright CLIエージェントスキルなどを導入するべきではないか?シナリオテストはできる?

  2. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    #447 (comment)

    結論: Playwright / Playwright CLI は導入すべき。Playwright CLI 用のエージェントスキル追加は #447 には混ぜない方がよいです。

    #447 はすでに @playwright/test devDependency、playwright.config.ts、pnpm test:e2e、test:e2e:ui/debug、trace、CI 統合、movement + projectile smoke test をスコープに入れています。つまり、人間コメントの前半は Issue 本文の意図と一致しています。現在の main の package.json には test:e2e も @playwright/test もまだ無いので、#447 で入れるのが妥当です。([GitHub]1) ([GitHub]2)

    Playwright CLI は別物としてグローバル導入するより、@playwright/test 由来の project-local CLI を pnpm exec playwright ... または package scripts 経由で使うべきです。公式 docs でも pnpm exec playwright test、--ui、--debug、install --with-deps、trace 設定が標準導線です。([Playwright]3) ([Playwright]4) ([Playwright]4) ([Playwright]5)

    推奨 package scripts はこの程度です。

    {
      "test:e2e": "playwright test",
      "test:e2e:ui": "playwright test --ui",
      "test:e2e:debug": "playwright test --debug",
      "test:e2e:headed": "playwright test --headed",
      "playwright:install": "playwright install chromium",
      "playwright:install:ci": "playwright install --with-deps chromium"
    }

    ただし .claude/skills/playwright-cli のような専用エージェントスキル追加は #447 の主目的から外れると見ます。#447 は browser playtest foundation の実装 Issue であり、エージェント運用手順の恒久化は .claude/agents/test-runner.md や implement-issue の責務変更になります。現在の implementation-worker / test-runner は Issue contract の VC を実行する役割で、開発環境 preflight や許可コマンドの管理も絡むため、ここを変えるなら 別 Issue がよいです。([GitHub]6) ([GitHub]7)

    シナリオテストはできます。ただし段階を分けるべきです。

    1. 実装: E2E / browser playtest foundation を導入し、movement + projectile の実ブラウザ検証導線を作る #447 でやるべき範囲
      movement + projectile の smoke scenario。例: Canvas 表示確認 → KeyW/KeyA/S/D 入力 → player state 変化確認 → pointer down/move/up → projectile 発生・移動確認 → trace 保存。これは Playwright の page.keyboard / page.mouse と DEV-only/test-only state hook で実装可能です。Issue 本文の AC5 と整合します。([GitHub]1)

    2. 実装: E2E / browser playtest foundation を導入し、movement + projectile の実ブラウザ検証導線を作る #447 でやり過ぎな範囲
      “面白さ”“操作感が良い”“UX 妥当性”の自動判定、長時間 combat-agent、telemetry 集計、複数シナリオ DSL、replay 管理。既存 playtest protocol は browser_automation を UI/Canvas/DOM 統合・リグレッションの根拠として許可していますが、UX 妥当性の代替は禁止しています。([GitHub]8)

    3. 後続 Issue に切るべき範囲
      tests/e2e/scenarios/**、scenario runner、events.jsonl / metrics.redacted.json 出力、playtest-log 自動生成、agent profile 管理。playtest-log には browser automation 用の automation metadata、metrics、trace_ref、input_script_ref などの構造が既にあるため、シナリオテスト基盤は後続で拡張できます。([GitHub]9)

    GitHub コメント案:

    賛成。ただし責務を分けたいです。
    
    #447 では Playwright Test 本体と project-local CLI 導線を導入するのが妥当です。具体的には `@playwright/test`、`playwright.config.ts`、`pnpm test:e2e`、`pnpm test:e2e:ui`、`pnpm test:e2e:debug`、CI 上の browser install / trace artifact を入れる。Playwright CLI はグローバル導入ではなく、package scripts / `pnpm exec playwright ...` 経由に限定するのがよいです。
    
    一方で、Playwright CLI 専用の Claude skill / agent skill を #447 に含めるのは反対です。これはアプリ側の E2E foundation ではなく、`.claude/agents/test-runner.md` や `implement-issue` の実行権限・VC 実行方針の変更になるため、別 Issue に分けるべきです。必要なら「test-runner が `pnpm test:e2e` / trace / report を扱えるようにする」改善 Issue を別途起票するのが安全です。
    
    シナリオテストは可能です。ただし #447 では full playtest agent ではなく、movement + projectile の smoke scenario までに限定したいです。
    
    - Canvas が表示される
    - WASD 入力で player state / position が変化する
    - pointer down/move/up で aim / firing が破綻しない
    - projectile が生成され、tick 後に移動する
    - failure 時に Playwright trace が残る
    - 自動 E2E 結果を UX 妥当性の証拠として扱わない
    
    長時間プレイ、combat-agent、scenario DSL、events.jsonl / metrics.json、playtest-log 自動生成は後続 Issue に分割するのがよいです。
  3. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    結論: REQUEST_CHANGES

    Issue #447 は方向性としては妥当です。PR #444 で deferred になっている「movement + projectile の実ブラウザ確認」を、Playwright ベースの E2E/playtest foundation として切り出す意図は正しいです。ただし、現状の Issue contract は緩すぎます。このままだと Playwright を入れて、rg に通るだけの空テストを書けば AC を満たせるため、「実ブラウザで動いた」ことを保証できません。Issue #447 は Playwright 導入、tests/e2e、trace、playtest log 導線、CI 統合または defer を要求していますが、検証コマンドの多くが grep/file-exists レベルに留まっています。(GitHub)

    さらに、#447 は PR #444 の deferred runtime verification を起点にしていますが、PR #444 は Draft 状態で、movement/projectile 実装そのものはまだ main に入っていません。#1 の親スコープは WASD movement、pointerdown 射撃、Projectile 更新・描画まで含む実装 Issue です。(GitHub)


    ブロッカー

    1. #444 依存の merge gate がない

    #447 は #444 の deferred destination として作られていますが、#444 が未マージのまま #447 を実装すると、次のどれかになります。

    リスク | 内容 -- | -- main で E2E が失敗 | movement/projectile 実装が存在しないため #447 が #1/#444 の実装を再実装 | test-infra Issue の責務を逸脱 #444 ブランチに依存した PR になる | merge order が contract にないためレビュー不能

    要求修正:

    ## Implementation Gate
    

    BLOCKED until PR #444 is merged into main and the target branch contains the movement + projectile runtime code from #1.

    If implementation starts before #444 is merged, this Issue MUST be implemented as a dependent PR targeting the #444 branch, and the PR body MUST explicitly state:

    • base PR / base branch

    • merge order

    • rebase condition after #444 merge

    これを入れない限り、Issue #447 は実装可能性が不安定です。


    2. AC と VC が一致していない。grep は browser verification ではない

    AC5 は「Canvas/keyboard/pointer の実ブラウザ検証」を要求していますが、VC は rg "keyboard|pointer|canvas|projectile" 程度です。これではコメントや空テストでも通ります。Playwright の公式 best practices は、テストは実装詳細ではなく user-visible behavior を検証すべきとしています。(Playwright)

    要求修正:

    AC5 を次のように具体化すべきです。

    AC5 revised:
    The E2E smoke test MUST verify all of the following in a real browser:

  4. app loads via Playwright webServer

  5. canvas is visible and has non-zero CSS and backing-store size

  6. pressing KeyW/KeyA/KeyS/KeyD changes player position in the expected axis

  7. keyup stops movement input

  8. pointer/mouse down on canvas creates at least one projectile

  9. projectile count or projectile position changes after the simulation advances

  10. pointerup stops primary fire input

  11. pointercancel or lostpointercapture clears the active pointer state

  12. VC も grep ではなく、実行結果を検証対象にするべきです。

    pnpm test:e2e
    pnpm test:e2e -- --project=chromium --reporter=list

    3. test-only observability hook の境界が危険

    #447 は src/** を「minimal test-only observability hook」に限って許可していますが、何を許すかが曖昧です。import.meta.env.DEV だけで守ると通常の開発サーバーにも hook が出ます。Vite は import.meta.env を compile-time 置換し、VITE_ prefix の値はクライアントに露出します。つまり hook flag は非 secret として扱う必要があります。(vitejs)

    要求修正:

    Observability hook contract:

  13. MUST be read-only.

  14. MUST NOT expose setters, dispatchers, or mutation functions.

  15. MUST NOT alter production runtime behavior.

  16. MUST be gated by an explicit E2E mode/flag, not generic DEV alone.

  17. MUST be absent from normal production build output.

  18. MAY expose a frozen snapshot such as:
    window.LOOP_E2E = {
    getSnapshot(): {
    player: { x, y },
    projectiles: [{ x, y, direction }],
    input: { primaryPressed, activePointerId }
    }
    }

  19. 追加 VC:

    pnpm build
    ! rg "LOOP_E2E|LOOP_E2E" dist

    ただし、E2E 用 production-like build で hook を使う設計にする場合は、通常 production build と e2e build を分離する必要があります。


    4. CI 統合が曖昧すぎる

    #447 は “CI integration or documented deferral” としていますが、Runtime Verification Applicability は required です。これは矛盾しています。Playwright の GitHub Actions 例では、依存 install に加えて playwright install --with-deps と test report artifact upload が示されています。(Playwright)

    既存 CI は typecheck/lint/test/build/python-test 中心で、Playwright browser install や test:e2e job はありません。(GitHub)

    要求修正:

    CI integration は defer ではなく必須にするべきです。最小構成:

    e2e:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:

    • uses: actions/checkout@v4
    • uses: pnpm/action-setup@v6
    • uses: actions/setup-node@v4
      with:
      node-version: 22
      cache: pnpm
    • run: pnpm install --frozen-lockfile
    • run: pnpm exec playwright install --with-deps chromium
    • run: pnpm test:e2e
    • uses: actions/upload-artifact@v4
      if: ${{ !cancelled() }}
      with:
      name: playwright-report
      path: |
      playwright-report/
      test-results/
      retention-days: 7

    CI を defer するなら、#447 の Runtime Verification Applicability: required を満たせません。別 Issue に分割するべきです。


    5. trace 設定の要求が不正確

    AC6 は「failure 時に trace 保存」と言っていますが、単に trace: 'on-first-retry' を書くだけでは、retry が発生しない失敗では trace が残りません。Playwright の trace docs では on-first-retry は retry 時に記録される設定です。(Playwright)

    要求修正:

    どちらかを明記してください。

    Option A:
    CI uses retries: 1 and trace: "on-first-retry".

    Option B:
    E2E smoke uses trace: "retain-on-failure" so first failure also keeps trace.

    「failure 時に必ず trace」が目的なら B です。


    6. Vite dev / preview のどちらを検証するか未定義

    #447 は “Vite preview/dev from Playwright” としていますが、これは曖昧です。Vite の preview は production build の preview であり、事前に vite build が必要です。(vitejs)

    推奨:

    production-like smoke に寄せるなら:

    webServer: {
    command: 'pnpm build && pnpm preview -- --host 127.0.0.1 --port 4173 --strictPort',
    url: 'http://127.0.0.1:4173',
    reuseExistingServer: !process.env.CI,
    timeout: 120_000,
    }

    Playwright 公式 config も webServer、baseURL、reuseExistingServer: !process.env.CI、CI retry/worker 制御を想定しています。(Playwright)


    7. playtest-log の責務を侵食する危険がある

    #447 は docs/playtest-log route を含みますが、既に docs/product/playtest-log.md には session mode、automation artifact、raw recording、trace redaction、UX evidence policy などの契約があります。また #419 は telemetry/event log contract を別 Issue として扱っています。(GitHub)

    #447 は test-infra Issue なので、playtest schema を変更すべきではありません。

    要求修正:

    Docs scope:

    • MAY add docs/product/playtest-sessions/README.md
    • MAY add one browser_automation sample session log
    • MUST NOT change playtest-log schema or UX evidence policy
    • MUST NOT introduce telemetry/event taxonomy changes; those belong to #419

    追加で入れるべき AC

    現状 AC1–AC10 に加えて、以下を追加した方がよいです。

    AC11: The Issue/PR explicitly declares dependency on PR #444 merge state.
    AC12: E2E tests contain behavioral assertions, not only file/string presence checks.
    AC13: Any test observability hook is read-only, e2e-gated, and absent from normal production build output.
    AC14: CI installs Playwright browsers and uploads non-committed failure artifacts.
    AC15: The playtest-log schema/policy is not changed by this Issue.

    修正後の Verification Commands 案

    pnpm typecheck
    pnpm lint
    pnpm test
    pnpm build
    pnpm test:e2e

    node -e "const p=require('./package.json'); if(!p.scripts['test:e2e']) process.exit(1)"
    node -e "const p=require('./package.json'); if(!p.devDependencies?.['@playwright/test']) process.exit(1)"

    test -f playwright.config.ts
    test -d tests/e2e

    rg "page.keyboard|keyboard.down|keyboard.press" tests/e2e
    rg "page.mouse|pointerdown|PointerEvent" tests/e2e
    rg "canvas" tests/e2e
    rg "projectile" tests/e2e

    pnpm build
    ! rg "LOOP_E2E|LOOP_E2E" dist

    rg "browser_automation" docs/product/playtest-sessions docs/product/playtest-log.md
    rg "ai_result_is_ux_evidence: false|not UX evidence|not_ux_evidence" docs/product/playtest-sessions docs/product/playtest-log.md


    レビューコメント案

    REQUEST_CHANGES

    Issue #447 の方向性は妥当ですが、現状の contract では Playwright 導入と grep だけで AC を満たせてしまい、PR #444 で deferred された「実ブラウザ上の movement + projectile 検証」を保証できません。

    Blockers:

    1. #444 が Draft/未マージであるにもかかわらず、#447 に Implementation Gate / merge order がない。
    2. AC5 は real browser verification を要求しているが、VC は rg/file-exists 中心で、空テストでも通る。
    3. src/** の observability hook 許可が広すぎる。read-only / e2e-gated / production build absent を contract 化すべき。
    4. Runtime Verification required なのに CI integration が “or deferral” になっている。
    5. trace 保存要件が不正確。on-first-retry だけでは first failure trace を保証しない。
    6. Vite dev と preview のどちらを検証するか未定義。
    7. playtest-log schema/policy は既存 docs と #419 の責務であり、#447 で変更すべきではない。

    修正要求:

    • #444 dependency gate を追加
    • AC5/VC を behavioral Playwright assertions に変更
    • observability hook contract を read-only/e2e-only に限定
    • CI e2e job + browser install + failure artifact upload を必須化
    • playtest-log schema 変更を out of scope に明記

    この修正を入れれば、#447 は「Playwright を入れた」ではなく「#1/#444 の runtime を実ブラウザで継続検証できる foundation を作った」と言える Issue になります。

    ## 結論: REQUEST_CHANGES

    Issue #447 は方向性としては妥当です。PR #444 で deferred になっている「movement + projectile の実ブラウザ確認」を、Playwright ベースの E2E/playtest foundation として切り出す意図は正しいです。ただし、現状の Issue contract は緩すぎます。このままだと Playwright を入れて、rg に通るだけの空テストを書けば AC を満たせるため、「実ブラウザで動いた」ことを保証できません。Issue #447 は Playwright 導入、tests/e2e、trace、playtest log 導線、CI 統合または defer を要求していますが、検証コマンドの多くが grep/file-exists レベルに留まっています。([GitHub]1)

    さらに、#447 は PR #444 の deferred runtime verification を起点にしていますが、PR #444 は Draft 状態で、movement/projectile 実装そのものはまだ main に入っていません。#1 の親スコープは WASD movement、pointerdown 射撃、Projectile 更新・描画まで含む実装 Issue です。([GitHub]2)


    ブロッカー

    1. #444 依存の merge gate がない

    #447 は #444 の deferred destination として作られていますが、#444 が未マージのまま #447 を実装すると、次のどれかになります。

    リスク 内容
    main で E2E が失敗 movement/projectile 実装が存在しないため
    #447 が #1/#444 の実装を再実装 test-infra Issue の責務を逸脱
    #444 ブランチに依存した PR になる merge order が contract にないためレビュー不能

    要求修正:

    ## Implementation Gate
    
    BLOCKED until PR #444 is merged into main and the target branch contains the movement + projectile runtime code from #1.
    
    If implementation starts before #444 is merged, this Issue MUST be implemented as a dependent PR targeting the #444 branch, and the PR body MUST explicitly state:
    - base PR / base branch
    - merge order
    - rebase condition after #444 merge

    これを入れない限り、Issue #447 は実装可能性が不安定です。


    2. AC と VC が一致していない。grep は browser verification ではない

    AC5 は「Canvas/keyboard/pointer の実ブラウザ検証」を要求していますが、VC は rg "keyboard|pointer|canvas|projectile" 程度です。これではコメントや空テストでも通ります。Playwright の公式 best practices は、テストは実装詳細ではなく user-visible behavior を検証すべきとしています。(Playwright)

    要求修正:

    AC5 を次のように具体化すべきです。

    AC5 revised:
    The E2E smoke test MUST verify all of the following in a real browser:
    
    - app loads via Playwright webServer
    - canvas is visible and has non-zero CSS and backing-store size
    - pressing KeyW/KeyA/KeyS/KeyD changes player position in the expected axis
    - keyup stops movement input
    - pointer/mouse down on canvas creates at least one projectile
    - projectile count or projectile position changes after the simulation advances
    - pointerup stops primary fire input
    - pointercancel or lostpointercapture clears the active pointer state

    VC も grep ではなく、実行結果を検証対象にするべきです。

    pnpm test:e2e
    pnpm test:e2e -- --project=chromium --reporter=list

    3. test-only observability hook の境界が危険

    #447 は src/** を「minimal test-only observability hook」に限って許可していますが、何を許すかが曖昧です。import.meta.env.DEV だけで守ると通常の開発サーバーにも hook が出ます。Vite は import.meta.env を compile-time 置換し、VITE_ prefix の値はクライアントに露出します。つまり hook flag は非 secret として扱う必要があります。([vitejs]4)

    要求修正:

    Observability hook contract:
    
    - MUST be read-only.
    - MUST NOT expose setters, dispatchers, or mutation functions.
    - MUST NOT alter production runtime behavior.
    - MUST be gated by an explicit E2E mode/flag, not generic DEV alone.
    - MUST be absent from normal production build output.
    - MAY expose a frozen snapshot such as:
      window.__LOOP_E2E__ = {
        getSnapshot(): {
          player: { x, y },
          projectiles: [{ x, y, direction }],
          input: { primaryPressed, activePointerId }
        }
      }

    追加 VC:

    pnpm build
    ! rg "__LOOP_E2E__|LOOP_E2E" dist

    ただし、E2E 用 production-like build で hook を使う設計にする場合は、通常 production build と e2e build を分離する必要があります。


    4. CI 統合が曖昧すぎる

    #447 は “CI integration or documented deferral” としていますが、Runtime Verification Applicability は required です。これは矛盾しています。Playwright の GitHub Actions 例では、依存 install に加えて playwright install --with-deps と test report artifact upload が示されています。(Playwright)

    既存 CI は typecheck/lint/test/build/python-test 中心で、Playwright browser install や test:e2e job はありません。([GitHub]6)

    要求修正:

    CI integration は defer ではなく必須にするべきです。最小構成:

    e2e:
      runs-on: ubuntu-latest
      timeout-minutes: 15
      steps:
        - uses: actions/checkout@v4
        - uses: pnpm/action-setup@v6
        - uses: actions/setup-node@v4
          with:
            node-version: 22
            cache: pnpm
        - run: pnpm install --frozen-lockfile
        - run: pnpm exec playwright install --with-deps chromium
        - run: pnpm test:e2e
        - uses: actions/upload-artifact@v4
          if: ${{ !cancelled() }}
          with:
            name: playwright-report
            path: |
              playwright-report/
              test-results/
            retention-days: 7

    CI を defer するなら、#447 の Runtime Verification Applicability: required を満たせません。別 Issue に分割するべきです。


    5. trace 設定の要求が不正確

    AC6 は「failure 時に trace 保存」と言っていますが、単に trace: 'on-first-retry' を書くだけでは、retry が発生しない失敗では trace が残りません。Playwright の trace docs では on-first-retry は retry 時に記録される設定です。(Playwright)

    要求修正:

    どちらかを明記してください。

    Option A:
    CI uses retries: 1 and trace: "on-first-retry".
    
    Option B:
    E2E smoke uses trace: "retain-on-failure" so first failure also keeps trace.

    「failure 時に必ず trace」が目的なら B です。


    6. Vite dev / preview のどちらを検証するか未定義

    #447 は “Vite preview/dev from Playwright” としていますが、これは曖昧です。Vite の preview は production build の preview であり、事前に vite build が必要です。([vitejs]8)

    推奨:

    production-like smoke に寄せるなら:

    webServer: {
      command: 'pnpm build && pnpm preview -- --host 127.0.0.1 --port 4173 --strictPort',
      url: 'http://127.0.0.1:4173',
      reuseExistingServer: !process.env.CI,
      timeout: 120_000,
    }

    Playwright 公式 config も webServer、baseURL、reuseExistingServer: !process.env.CI、CI retry/worker 制御を想定しています。([Playwright]9)


    7. playtest-log の責務を侵食する危険がある

    #447 は docs/playtest-log route を含みますが、既に docs/product/playtest-log.md には session mode、automation artifact、raw recording、trace redaction、UX evidence policy などの契約があります。また #419 は telemetry/event log contract を別 Issue として扱っています。([GitHub]10)

    #447 は test-infra Issue なので、playtest schema を変更すべきではありません。

    要求修正:

    Docs scope:
    - MAY add docs/product/playtest-sessions/README.md
    - MAY add one browser_automation sample session log
    - MUST NOT change playtest-log schema or UX evidence policy
    - MUST NOT introduce telemetry/event taxonomy changes; those belong to #419

    追加で入れるべき AC

    現状 AC1–AC10 に加えて、以下を追加した方がよいです。

    AC11: The Issue/PR explicitly declares dependency on PR #444 merge state.
    AC12: E2E tests contain behavioral assertions, not only file/string presence checks.
    AC13: Any test observability hook is read-only, e2e-gated, and absent from normal production build output.
    AC14: CI installs Playwright browsers and uploads non-committed failure artifacts.
    AC15: The playtest-log schema/policy is not changed by this Issue.

    修正後の Verification Commands 案

    pnpm typecheck
    pnpm lint
    pnpm test
    pnpm build
    pnpm test:e2e
    
    node -e "const p=require('./package.json'); if(!p.scripts['test:e2e']) process.exit(1)"
    node -e "const p=require('./package.json'); if(!p.devDependencies?.['@playwright/test']) process.exit(1)"
    
    test -f playwright.config.ts
    test -d tests/e2e
    
    rg "page.keyboard|keyboard.down|keyboard.press" tests/e2e
    rg "page.mouse|pointerdown|PointerEvent" tests/e2e
    rg "canvas" tests/e2e
    rg "projectile" tests/e2e
    
    pnpm build
    ! rg "__LOOP_E2E__|LOOP_E2E" dist
    
    rg "browser_automation" docs/product/playtest-sessions docs/product/playtest-log.md
    rg "ai_result_is_ux_evidence: false|not UX evidence|not_ux_evidence" docs/product/playtest-sessions docs/product/playtest-log.md

    レビューコメント案

    REQUEST_CHANGES
    
    Issue #447 の方向性は妥当ですが、現状の contract では Playwright 導入と grep だけで AC を満たせてしまい、PR #444 で deferred された「実ブラウザ上の movement + projectile 検証」を保証できません。
    
    Blockers:
    
    1. #444 が Draft/未マージであるにもかかわらず、#447 に Implementation Gate / merge order がない。
    2. AC5 は real browser verification を要求しているが、VC は rg/file-exists 中心で、空テストでも通る。
    3. src/** の observability hook 許可が広すぎる。read-only / e2e-gated / production build absent を contract 化すべき。
    4. Runtime Verification required なのに CI integration が “or deferral” になっている。
    5. trace 保存要件が不正確。on-first-retry だけでは first failure trace を保証しない。
    6. Vite dev と preview のどちらを検証するか未定義。
    7. playtest-log schema/policy は既存 docs と #419 の責務であり、#447 で変更すべきではない。
    
    修正要求:
    - #444 dependency gate を追加
    - AC5/VC を behavioral Playwright assertions に変更
    - observability hook contract を read-only/e2e-only に限定
    - CI e2e job + browser install + failure artifact upload を必須化
    - playtest-log schema 変更を out of scope に明記

    この修正を入れれば、#447 は「Playwright を入れた」ではなく「#1/#444 の runtime を実ブラウザで継続検証できる foundation を作った」と言える Issue になります。

  20. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    Contract Snapshot (2026-05-28T15:41:20Z)

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-05-28T15:41:20Z"
      generated_by: issue-contract-review
      issue_url: "https://github.com/squne121/loop-protocol/issues/447"
      checks:
        template_compliance: pass
        state_label: ok
        allowed_paths_present: pass
        vc_present: pass
        stop_conditions_complete: pass
        vc_preflight:
          passed: true
          vc_failed_as_expected: 7
          vc_passed_unexpectedly: 0
          vc_unrunnable: 0
          vc_expected_pass: 5
          vc_skipped: 9
          classifications:
            - ac: AC1
              command: "node -e \"const p=require('./package.json'); ...\""
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC2
              command: "node -e \"const p=require('./package.json'); ...\""
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC3
              command: "test -f playwright.config.ts"
              exit_code: 1
              classification: expected_fail
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC4
              command: "test -d tests/e2e"
              exit_code: 1
              classification: expected_fail
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC4
              command: "rg -n \"projectile|pointer|...\" tests/e2e"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "tests/e2e dir not yet created; runtime verification required"
              runtime_verification_required: true
            - ac: AC5
              command: "pnpm test:e2e"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "Playwright browser runtime required"
              runtime_verification_required: true
            - ac: AC5
              command: "pnpm test:e2e -- --project=chromium --reporter=list"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "Playwright browser runtime required"
              runtime_verification_required: true
            - ac: AC6
              command: "rg -n \"retain-on-failure|on-first-retry\" playwright.config.ts"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "playwright.config.ts not yet created"
              runtime_verification_required: false
            - ac: AC7
              command: "pnpm test:e2e"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "Playwright browser runtime required"
              runtime_verification_required: true
            - ac: AC8
              command: "pnpm typecheck"
              classification: expected_pass
              category: regression_gate
              scope_class: regression_gate
              confidence: high
              decision: go
            - ac: AC8
              command: "pnpm lint"
              classification: expected_pass
              category: regression_gate
              scope_class: regression_gate
              confidence: high
              decision: go
            - ac: AC8
              command: "pnpm test"
              classification: expected_pass
              category: regression_gate
              scope_class: regression_gate
              confidence: high
              decision: go
            - ac: AC8
              command: "pnpm build"
              classification: expected_pass
              category: regression_gate
              scope_class: regression_gate
              confidence: high
              decision: go
            - ac: AC9
              command: "rg -n \"browser_automation|human_internal\" docs/..."
              classification: skipped
              scope_class: pr_review_only
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "existing docs verification, not implementation-dependent"
              runtime_verification_required: false
            - ac: AC9
              command: "test -d docs/product/playtest-sessions"
              exit_code: 1
              classification: expected_fail
              category: file_not_found_expected
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC10
              command: "rg -n \"UX|妥当性|...\" docs/product playwright.config.ts"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "playwright.config.ts not yet created; runtime check"
              runtime_verification_required: false
            - ac: AC11
              command: "rg -n \"expect|toBeVisible|...\" tests/e2e"
              classification: skipped
              scope_class: runtime_only
              decision: go
              verification_owner: impl-review-loop
              deferred_reason: "tests/e2e not yet created"
              runtime_verification_required: true
            - ac: AC12
              command: "pnpm build"
              classification: expected_pass
              category: regression_gate
              scope_class: regression_gate
              confidence: high
              decision: go
            - ac: AC12
              command: "! rg \"__LOOP_E2E__|LOOP_E2E\" dist"
              exit_code: ~
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC13
              command: "rg -n \"playwright install|playwright-report|test-results\" .github/workflows"
              exit_code: 1
              classification: expected_fail
              category: expected_baseline_fail
              scope_class: baseline_fail_expected
              confidence: high
              decision: go
            - ac: AC14
              command: "git diff main -- docs/product/playtest-log.md | ..."
              classification: skipped
              scope_class: pr_review_only
              decision: go
              verification_owner: pr-review-judge
              deferred_reason: "diff-against-main check only valid at PR review time"
              runtime_verification_required: false
        ac_verifiability: pass
        product_spec_check:
          applicability: applicable
          decision: pass
          triggers:
            docs_product_allowed_paths: true
            tasks_md_mentioned: false
            specify_artifact_mentioned: false
            generated_task_mentioned: false
            product_spec_context_present: true
          conditions:
            docs_product_requires_spec_evidence:
              status: pass
              evidence:
                - "Product Spec Context section present"
            diff_first_rationale_present:
              status: pass
              evidence:
                - "Product Spec Context with diff_rationale present"
        worktree_branch_collision: clear
      next_action: implement_issue
      blocked_reasons: []
      warnings:
        - "scope_rollup: high-confidence candidate #448 (playtest execution) exists but is separate responsibility; not merged"

    Contract Details

    • Outcome: Playwright ベース最小 E2E foundation 導入。pnpm test:e2e でローカル/CI から movement + projectile smoke test を実行できる状態にする
    • Acceptance Criteria: AC1–AC14
    • Worktree: .claude/worktrees/issue-447-e2e-browser-playtest-foundation-movement
    • Branch: worktree-issue-447-e2e-browser-playtest-foundation-movement
    • VC preflight: baseline fail = 7, expected pass = 5, skipped = 9, blocked = 0
    • Product Spec: applicable / pass (additive-sample-only, no schema change)
    • Runtime Verification: decision: immediate, applicable_acs: [AC5, AC7]
  21. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    implement-issue: 実装完了 (2026-05-28T15:51:33Z)

    • PR: feat(#447): E2E / browser playtest foundation — movement + projectile smoke test #451
    • Worktree: .claude/worktrees/issue-447-e2e-browser-playtest-foundation-movement
    • Branch: worktree-issue-447-e2e-browser-playtest-foundation-movement
    • Verification: 4/4 PASS (typecheck / lint / test 127件 / build)
    • E2E: 11/11 PASS (pnpm test:e2e, Chromium)
    • AC12: production build に __LOOP_E2E__ 不在確認済み
    • 後続: PR レビュー(pr-review-judge)→ マージ → post-merge-cleanup
  22. added 4 commits that reference this issue on May 28, 2026
  23. squne121 commented on May 28, 2026

    @squne121
    OwnerAuthor

    post-merge-cleanup: 完了 (2026-05-29T00:00:00Z)

    • status: ok
    • 次アクション: なし(Issue は既にクローズ済み)
    FOLLOW_UP_MATERIALIZATION_RESULT_V1:
      schema_version: 1
      materialized_by: post-merge-cleanup
      follow_up_issues: []
      note_only_observations: []

    実施内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    phase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions