Skip to content

実装: PR#854 save→reload 証跡を playtest docs に追加 #860

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "#740"
goal_ref: "PR#854 の save→reload→restore happy-path 証跡を HTTP origin で playtest docs に残す"
change_kind: docs

Parent Issue

#740

Parent Goal Ref

  • Goal: sortie→reward→localStorage 保存→reload→復元の loop を E2E / 手動 playtest で確認する証跡を残す
  • Desired Destination: docs/playtest/m3-loop-mvp.md

Current Validated Scope

  • 実装: PR#854 save→reload 証跡を playtest docs に追加 #860 は docs-only follow-up として扱い、実際の成果物作成対象は docs/playtest/m3-loop-mvp.md に限定する
  • current default branch には docs/playtest/m3-loop-mvp.md が存在しないため、本 issue では「追記」ではなく Allowed Paths 内での新規作成を許可する
  • docs/product/features/persistence.md は storage key loop-protocol.mvp.save、HTTP origin 前提、file:// 非保証、GitHub Pages production / PR preview の key 共有注意を正本として定義している
  • Verification Commands は baseline preflight を決定論的に通すため docs/playtest/ 配下のみを検索対象にしてよいが、他ファイル編集は In Scope に含めない
  • src/main.ts では reward claim 後の happy-path save wiring は存在するが、save failure 時に hasLoadableSnapshot = false へ落とす既知ギャップが残っている

Remaining Parent Gaps

Outcome

docs/playtest/m3-loop-mvp.md を新規作成し、PR #854 で確認できた reward claim 後の save→reload→restore happy-path manual evidence を HTTP origin 前提で記録する。同時に、この証跡が #740 の E2E 残件や save failure boundary 未解決を置き換えないことを明記する。

Scope Clarification

This issue is a docs-only evidence follow-up for PR #854.
It does not close #740 by itself because #740 still requires Playwright E2E coverage and parent-level runtime sign-off.

In Scope

  • docs/playtest/m3-loop-mvp.md の新規作成
  • HTTP origin 上で採取した save→reload→restore happy-path manual evidence の記録
  • loop-protocol.mvp.save の raw JSON と parsed fields の記録
  • reward claim 後の resources 復元結果と combat runtime 再初期化の観察結果を記録
  • production / PR preview が同一 origin / key を共有し得る注意と事前 clear 手順の記載
  • save failure / QuotaExceededError path と 実装: M3 loop の sortie→reward→reload 復元を E2E / playtest で検証する #740 E2E 未充足を limitation として明記

Out of Scope

Acceptance Criteria

  • AC1: docs/playtest/m3-loop-mvp.md が存在し、実装: PR#854 save→reload 証跡を playtest docs に追加 #860 が docs-only happy-path evidence follow-up であることを明記している
  • AC2: 証跡が file:// ではなく HTTP origin を使用し、origin・command・browser・commit を記録している
  • AC3: 証跡に localStorage.removeItem('loop-protocol.mvp.save') の事前実行、保存キー名、raw JSON、parsed schemaVersion / resources / weaponPower / playerMaxHp が記録されている
  • AC4: 証跡に reward claim 後と reload 後の resources、および reload 後に loopPhase = preparation、enemies / projectiles が空、current HP は persistence 対象外である旨が記録されている
  • AC5: limitation として「write failure / QuotaExceededError path は本 issue では未証明」「save failure が older readable snapshot を invalid に見せない保証は未解決」「実装: M3 loop の sortie→reward→reload 復元を E2E / playtest で検証する #740 の Playwright E2E は別途必要」を明記している
  • AC6: production / PR preview が同一 origin / key を共有し得る注意と、preview / local 検証前の clear 手順を明記している

Verification Commands

# AC1
$ test -f docs/playtest/m3-loop-mvp.md

# AC2
$ rg -z -P "doc_id: playtest-m3-loop-mvp(?s).*HTTP origin.*origin:.*command:.*browser:.*commit:" docs/playtest

# AC3
$ rg -z -P "doc_id: playtest-m3-loop-mvp(?s).*localStorage\.removeItem\('loop-protocol\.mvp\.save'\).*raw JSON.*schemaVersion.*resources.*weaponPower.*playerMaxHp" docs/playtest

# AC4
$ rg -z -P "doc_id: playtest-m3-loop-mvp(?s).*resources after claim.*resources after reload.*loopPhase = preparation.*enemies/projectiles.*current HP" docs/playtest

# AC5
$ rg -z -P "doc_id: playtest-m3-loop-mvp(?s).*QuotaExceededError.*happy-path only.*未証明.*未解決.*#740" docs/playtest

# AC6
$ rg -z -P "doc_id: playtest-m3-loop-mvp(?s).*PR preview.*production.*同一 origin.*同一 key.*clear" docs/playtest

Runtime Verification Applicability

Allowed Paths

  • docs/playtest/m3-loop-mvp.md

Stop Conditions

  • docs/playtest/m3-loop-mvp.md 以外のファイル編集が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • なし

Source

dedupe_key: follow-up:squne121/loop-protocol:pr/854:4
source_url: "#854 (comment)"

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    on Jun 13, 2026
  2. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    判定

    条件付き REQUEST_CHANGES。
    #860 は「PR #854 の save→reload 証跡を playtest docs に残す」docs-only follow-up としては方向性がありますが、#740 / #739 の完了証跡として扱うには過小スコープです。Issue 本文は change_kind: docs、Allowed Paths は docs/playtest/m3-loop-mvp.md のみ、コメントは現時点で空です。

    #740 は本来、tests/e2e/ への sortie→reward→保存→reload→復元 E2E 追加と、docs/playtest/m3-loop-mvp.md の作成・手順記載を要求しています。AC も E2E、resources 加算、reload 復元、playtest doc の存在を含みます。([GitHub]1)
    一方 #860 は docs だけなので、#740 を閉じるための Issue ではなく、PR #854 の不足証跡を補う限定 Issue と明記すべきです。

    主要ブロッカー

    1. docs-only 証跡が、既知の実装欠陥を「合格扱い」に見せる危険

    現行 src/main.ts では persistProgressionSnapshot() が storage.save() 失敗時に hasLoadableSnapshot = false に落とします。これは「今回の保存失敗」と「既存 snapshot が読めるか」を混同します。
    onQuickLoad() は hasLoadableSnapshot を Quick Load 可否の前提にしているため、既存セーブが存在しても、直近の書き込み失敗で UI 上ロード不能に見える経路があります。

    MDN でも Storage.setItem() は QuotaExceededError を投げ得ると説明されており、保存失敗は正常に設計すべき I/O 境界です。さらに Storage は文字列保存なので、snapshot は JSON 変換境界も含みます。([MDN Web Docs]2)
    #860 はこの欠陥を修正しないので、playtest doc には “happy path evidence only / write failure boundary は未解決” と明記しないと、証跡として誤誘導になります。

    2. docs/playtest/m3-loop-mvp.md の扱いが曖昧

    #740 では docs/playtest/m3-loop-mvp.md は「新規作成」対象です。([GitHub]1)
    #860 は「追記」と書いていますが、こちらの確認では current default branch から docs/playtest/m3-loop-mvp.md を取得できませんでした。したがって、Issue 契約は次のどちらかに寄せるべきです。

    • 既存ファイルがないなら、Allowed Paths 内で新規作成を許可する。
    • 既に別 PR で作る前提なら、Depends on その PR/Issue を明記する。

    この曖昧さは AI エージェントが「存在しないファイルへの追記」で停止、または勝手に別ファイルへ追記する原因になります。

    3. PR #854 の実装証跡と #860 の証跡が混線している

    PR #854 は claimPendingReward(state) 成功後に persistProgressionSnapshot('reward-claim') を呼び、Quick Save も同 helper に集約していますが、追加テストは createGameSnapshot() が runtime fields を含まないことの確認に寄っています。
    #739 の AC は、報酬確定後に resources を含む snapshot が保存され、page reload 後に復元され、戦闘中 state が保存対象外で、保存が tick ではなく限定ポイントだけで行われることです。([GitHub]3)

    #860 の docs 証跡は、最低限次を分離して書く必要があります。

    技術・配布物観点の指摘

    HTTP origin 証跡は必須

    localStorage は origin に紐づき、HTTP と HTTPS でも別 storage になります。file: URL の localStorage 挙動は未定義で、ブラウザ差分もあり得ます。([MDN Web Docs]4)
    Vite 公式も、build output は既定で dist、vite preview は dist をローカル静的サーバーで確認する用途だと説明しています。([vitejs]5)

    したがって #860 の playtest doc は、単に「reload した」では不足です。次を必須項目にしてください。

    ## Save → Reload → Restore Evidence
    
    - build/source:
      - commit:
      - command:
      - origin:
      - browser:
    - precondition:
      - localStorage.removeItem('loop-protocol.mvp.save') executed:
      - initial resources:
    - action:
      - sortie result:
      - reward claim clicked:
      - resources after claim:
    - storage assertion:
      - key: loop-protocol.mvp.save
      - raw JSON:
      - parsed schemaVersion:
      - parsed resources:
      - parsed weaponPower:
      - parsed playerMaxHp:
    - reload assertion:
      - page.reload performed:
      - resources after reload:
      - loopPhase after reload:
      - enemies/projectiles after reload:
    - limitation:
      - write failure / QuotaExceededError path:
      - previous snapshot preservation:

    Playwright で自動化する場合は、page.evaluate() でブラウザ側の window / document / localStorage を読めますし、page.reload() はユーザーの refresh と同じ形で現在ページを再読込します。([Playwright]6) ([Playwright]7)

    same-origin key 共有の注意は具体化が必要

    docs/product/features/persistence.md は、storage key を loop-protocol.mvp.save とし、HTTP origin 前提、file:// 非保証、さらに GitHub Pages の本番 path と PR preview path が同一 origin/key を共有し得るため、E2E/preview では事前 clear が必要だと定義しています。
    #860 の AC にある「PR preview/本番 origin の key 共有注意」は正しいですが、文言だけでは弱いです。手順として clear コマンドを必須化してください。

    localStorage.removeItem('loop-protocol.mvp.save')

    また、PR #854 の preview コメントは「PR が closed されると preview は削除される」としています。PR #854 は merged/closed 済みなので、#860 実施時の証跡 origin は PR #854 preview ではなく、current production preview または vite preview の HTTP origin に寄せるべきです。

    Issue #860 の修正文案

    #860 は次のように契約を変えるのが安全です。

    ## Scope Clarification
    
    This issue is a docs-only evidence follow-up for PR #854.
    It does not close #740 by itself because #740 also requires Playwright E2E coverage.
    
    ## In Scope
    
    - Create or update `docs/playtest/m3-loop-mvp.md`
    - Add HTTP-origin manual evidence for save → reload → restore
    - Record exact localStorage key, origin, raw snapshot, parsed fields, and reload result
    - Mark PR #854 evidence as happy-path only
    - Explicitly document unresolved failure-boundary gaps:
      - save failure must not invalidate an older readable snapshot
      - write failure / QuotaExceededError path is not proven here
      - automated E2E remains for #740
    
    ## Acceptance Criteria
    
    - [ ] `docs/playtest/m3-loop-mvp.md` exists.
    - [ ] Evidence uses HTTP origin, not `file://`.
    - [ ] Evidence includes `localStorage.removeItem('loop-protocol.mvp.save')` precondition.
    - [ ] Evidence includes before/after `resources`.
    - [ ] Evidence includes raw and parsed `loop-protocol.mvp.save`.
    - [ ] Evidence verifies reload restores progression fields only.
    - [ ] Evidence states combat runtime is reinitialized: `loopPhase = preparation`, enemies/projectiles empty, current HP not persisted.
    - [ ] Evidence warns that GitHub Pages production and PR preview may share the same origin/key.
    - [ ] Evidence explicitly states that this does not satisfy #740 E2E ACs.

    最終判断

    この Issue を AI エージェントへそのまま渡すと、**「docs に成功手順を書いただけで #740/#739 が完了したように見える」**リスクが高いです。
    実装させる前に、#860 を docs-only happy-path evidence issue として再定義し、#740 の E2E 残件・#854 の保存失敗境界バグを明記してください。

  3. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-13T06:25:18Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/860
      body_sha256: "sha256:bad1d20ababc72a91e02702956c887abe1db69197840ed6c41b3c9247400610d"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  5. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-13T07:14:22Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/860
      body_sha256: "sha256:0f19aaf657630ced3f8e64347457c8aad42292b9686401c27ac7a639e86bea8e"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  6. squne121 commented on Jun 13, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-13T07:16:02Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/860
      body_sha256: "sha256:548734a1a780e085a3b7045d4c7a501e4ed1b7dd6b533d5b92c1ddf3dbacbb85"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
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

    agent/implementerenhancementphase/implementation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions