Skip to content

実装: UI runtime に Canvas cue / DOM HUD 責務分離を反映し raw enum を通常 UI から除去する #1173

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "none"
goal_ref: "ui-information-architecture.md の Canvas cue / DOM HUD / debug-evidence surface 境界を runtime に反映し、通常 UI から raw state と debug-only vocabulary を除去する"
change_kind: code

Parent Issue

none(単独改善)

Parent Goal Ref

  • Goal: docs/product/features/ui-information-architecture.md を runtime SSOT として反映し、Canvas は world + visual cue 専用、DOM HUD は player-facing status / command affordance 専用、raw telemetry / LoopPhase / exact internal state は opt-in debug or evidence surface に隔離する
  • Desired Destination: N/A(単独改善 Issue のため)

Current Validated Scope

  • src/ui/HudController.ts の通常 HUD から Loop Phase / Telemetry / Claim reward などの debug-only vocabulary と raw state 露出を除去し、player-facing copy に置き換える
  • src/render/CanvasRenderer.ts の primary HUD / status / result text を Canvas から外し、Canvas は world + visual cue に限定する
  • src/render/renderUtils.ts の enemy HP label は、残す場合のみ non-authoritative world cue として扱い、通常 HUD の primary status surface と混同しない境界をテストで固定する
  • raw telemetry / LoopPhase / exact values は default-on normal UI に出さず、既存の opt-in evidence surface(?playtest_evidence=1)または既存 debug-only surface に限定する

Remaining Parent Gaps

なし(単独改善 Issue のため)

Outcome

通常 UI で LoopPhase / telemetry / raw reward state / exact internal state が露出せず、src/render/CanvasRenderer.ts が primary HUD/control/debug text を描かない一方で、必要なら enemy HP label は non-authoritative world cue として限定的に残され、default-on ではない debug/evidence surface のみに raw state が隔離された状態で、pnpm typecheck / pnpm lint / pnpm test / pnpm build が PASS した PR がマージされた状態。

In Scope

  • src/ui/HudController.ts の通常 HUD から forbidden normal-play vocabulary と raw state 露出を除去する
  • LoopPhase 分岐を内部実装として保持してもよいが、render 後の通常 UI 文言は player-facing copy のみとする
  • src/render/CanvasRenderer.ts の stage label / elapsed timer / result summary など primary HUD text を DOM HUD or menu overlay 相当へ移すか、通常 UI から除去する
  • src/render/renderUtils.ts の enemy HP label を残す場合は non-authoritative world cue として明示し、境界テストで固定する
  • raw telemetry / exact values / reward pipeline state を default-on normal UI に出さず、?playtest_evidence=1 の evidence surface または既存 debug-only surface のみに留める
  • 上記境界を unit / E2E / semantics tests で回帰固定する

Out of Scope

Acceptance Criteria

  • AC1: pnpm typecheck が PASS する
  • AC2: pnpm lint が PASS する
  • AC3: pnpm test が PASS する
  • AC4: pnpm build が PASS する
  • AC5: 通常 HUD の render 後 DOM / accessible name に Loop Phase / Telemetry / Claim reward / reward pending / title_menu / load_menu / debrief_pending_reward / debrief_reward_claimed などの forbidden normal-play vocabulary が露出しないことがテストで固定されている
  • AC6: HudController.ts は内部で LoopPhase を分岐してよいが、通常 UI の status / command copy は player-facing wording のみを表示することがテストで固定されている
  • AC7: src/render/CanvasRenderer.ts が primary HUD / status / control / result text を fillText で描画しないことがテストまたは source-boundary check で固定されている
  • AC8: enemy HP label を残す場合、src/render/renderUtils.ts のみで non-authoritative world cue として扱われ、通常 HUD の primary status surface 代替になっていないことがテストで固定されている
  • AC9: raw telemetry / LoopPhase / exact values は default-on normal UI ではなく、?playtest_evidence=1 の opt-in evidence surface または既存 debug-only surface にのみ現れることがテストで固定されている

Verification Commands

# AC1
$ pnpm typecheck

# AC2
$ pnpm lint

# AC3
$ pnpm test

# AC4
$ pnpm build

# AC5
$ rg -n "normal-play vocabulary boundary" tests/hud-controller.test.ts

# AC6
$ rg -n "player-facing copy boundary" tests/hud-controller.test.ts

# AC7
# baseline-expect: fail
$ test -f tests/canvas-renderer-ui-boundary.test.ts

# AC8
$ rg -n "non-authoritative world cue boundary" tests/render/renderUtils.test.ts

# AC9
$ rg -n "opt-in debug evidence boundary" tests/playtest-evidence-semantics.test.ts

Allowed Paths

  • src/ui/HudController.ts
  • src/ui/playtestEvidence.ts
  • src/ui/index.ts
  • src/render/CanvasRenderer.ts
  • src/render/renderUtils.ts
  • src/main.ts
  • src/style.css
  • tests/hud-controller.test.ts
  • tests/render/renderUtils.test.ts
  • tests/playtest-evidence.test.ts
  • tests/playtest-evidence-semantics.test.ts
  • tests/e2e/assist-player-affordance.spec.ts
  • tests/e2e/m3-loop-mvp.spec.ts
  • tests/e2e/screenshots/m2-combat-mvp.spec.ts/m2-timeout-overlay-baseline.png
  • tests/canvas-renderer-ui-boundary.test.ts

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
  • PhaseTransitionSystem 相当の phase mutation / transition 責務に踏み込む必要が出た場合(実装: PhaseTransitionSystem を導入して LoopPhase 遷移を一元管理する #1174 に委譲)
  • playtestEvidence.ts の export schema / provenance contract / snapshot atomicity を変更しないと成立しない場合
  • enemy HP label を完全撤去するために docs/product/features/combat-core.md や 実装: Player 向け HP / HULL 表示ポリシーを通常 UI に適用する #788 系 policy / tests まで同時更新が必要と判明した場合
  • 新規の常時表示 debug panel や大規模 UI 再設計が必要になった場合

Notes for Reviewer

  • AC5 / AC6 は source grep ではなく render 後 DOM / accessible name 境界を固定すること。title_menu だけ消して Loop Phase / Telemetry / Claim reward が残る実装は不合格。
  • AC7 は src/render/CanvasRenderer.ts の primary HUD text を対象にする。src/render/ 全体の fillText 全廃は本 Issue の契約ではない。
  • AC8 は enemy HP label を残すなら world cue 扱いであることを明示し、通常 HUD の primary status 代替にしないこと。完全撤去が必要なら Stop Condition を踏んでスコープ再判定すること。
  • AC9 の debug/evidence surface は ?playtest_evidence=1 の opt-in を維持すること。default-on normal UI へ raw telemetry / exact values を戻してはならない。
  • phase transition behavior、button enable policy、reward pipeline semantics の変更は 実装: PhaseTransitionSystem を導入して LoopPhase 遷移を一元管理する #1174 または別 Issue の責務とする。
  • 実装後の人間レビューでは docs/product/features/ui-information-architecture.md に従い、viewport 1280x720 / 1366x768 / 1920x1080、browser zoom 100% / 125% / 150% / 200%、observed DPR、userAgent、commit SHA を伴う evidence capture を確認すること。

Required Skills

  • TypeScript
  • DOM / Canvas API(責務分離の境界)
  • Vitest / Playwright(surface boundary の回帰固定)

Runtime Verification Applicability

  • decision: deferred
  • reason: 本 Issue は静的検証と source / test boundary 固定で大部分を担保できる一方、viewport / zoom / DPR / readable status copy の最終確認は実装後の統合 UI と人間レビュー証跡を伴って初めて成立するため
  • deferred_destination:
    • destination_type: phase
    • destination_ref: implementation PR review
  • deferred_verification_condition: 実装 PR で通常 UI と opt-in evidence surface が起動可能な状態になり、docs/product/features/ui-information-architecture.md に基づく viewport 1280x720 / 1366x768 / 1920x1080、browser zoom 100% / 125% / 150% / 200%、observed DPR、userAgent、commit SHA を伴う evidence capture を人間レビューで確認できること

Scope Delta(任意)

owner comment https://github.com/squne121/loop-protocol/issues/1173#issuecomment-4848326479 を一次ソースとして反映。AC5 の浅い literal grep を render 後 vocabulary boundary に差し替え、AC6 の src/render/ 全体 fillText 禁止を CanvasRenderer.ts の primary HUD text 境界へ狭め、tests / evidence / #1174 boundary を明文化した。

Activity

  1. added
    enhancement
    phase/implementation
    triage-required
    agent/implementer
    on Jun 25, 2026
  2. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor

    判定: REQUEST_CHANGES / このまま実装に流すべきではない

    #1173 の方向性自体は正しいです。ui-information-architecture.md が定義した「Canvas は world + visual cue、DOM HUD は player-facing status / command affordance、debug panel は raw telemetry」という責務分離を runtime に反映する Issue です。#1173 自体にコメントはなく、本文だけが契約になっています。

    ただし、現状の契約は 実装者が grep を満たすだけの浅い修正をして、UI IA の本質を満たさない PR を出せる 状態です。敵対的に見ると、AC5 と AC6 はどちらも危険です。

    重大ブロッカー

    1. AC5 が弱すぎる。「title_menu をそのまま出さない」では UI IA を満たさない

    #1173 の AC5 は src/ui/HudController.ts に raw LoopPhase 値 "title_menu" をそのまま DOM 出力する箇所がないことだけを確認します。これは不十分です。現在の HudController.ts は raw enum 文字列を "Title Menu" に変換しているため、AC5 だけならすでにほぼ通せますが、通常 HUD には Loop Phase、Sortie Status、Telemetry、Claim reward という UI IA 上の forbidden vocabulary / debug-only vocabulary が残っています。

    UI IA は、通常プレイ UI で LoopPhase、Telemetry、Claim reward、raw internal state name、exact internal HP/HULL、fractional HP/HULL、<1 を直接出さないことを明示しています。さらに、DOM HUD overlay では player-facing status と command affordance は許可されますが、telemetry dump、LoopPhase、raw reward state、developer-only toggle は禁止です。

    修正要求: AC5 は literal grep ではなく、render 後 DOM / accessible name の語彙検査に変えるべきです。title_menu だけではなく、Loop Phase、Telemetry、Claim reward、reward pending、debrief_pending_reward、debrief_reward_claimed、raw sortie.status、raw command intent まで禁止対象に含める必要があります。

    2. AC6 の「src/render 配下に Canvas fillText が残っていない」は過剰で、既存仕様と衝突する

    #1173 の AC6 は rg -rn "fillText" src/render がヒットしないことを期待しています。しかし現在の src/render には少なくとも 2 系統の fillText があります。CanvasRenderer.ts では HUD テキストとして stageLabel と経過秒を描き、result overlay として outcome / duration / kills も描いています。

    さらに renderUtils.ts の drawEnemyHpLabel() は enemy HP label を fillText で描きます。これは #788 の integer-only normal UI policy とテストで固定済みです。

    外部仕様面でも、fillText() は Canvas 座標へ文字列を描画する API であり、DOM の semantic text や accessible control の代替にはなりません。MDN は <canvas> が bitmap であり、描画されたオブジェクトは semantic HTML として accessibility tree に公開されないと説明しています。([MDNウェブドキュメント]1) ([MDNウェブドキュメント]2)

    修正要求: AC6 は次のどちらかに分岐させるべきです。

    現実的には B案です。ただし UI IA は numeric exactness より visual cue を優先するとしているため、enemy HP label を残すなら「暫定的な non-authoritative cue」と明文化し、将来の silhouette/gauge/damage cue 置換候補として残すのが妥当です。

    3. Allowed Paths に tests がないため、まともな回帰固定ができない

    #1173 は pnpm test を AC に置いていますが、Allowed Paths に tests/ がありません。DOM vocabulary boundary、Canvas text boundary、debug-only raw telemetry boundary は、grep ではなくテストで固定しないと再発します。#986 は assist_player の DOM affordance / Canvas cue 実装で tests/ と E2E evidence を使い、viewport / zoom / DPR の証跡まで残しています。

    修正要求: Allowed Paths に少なくとも以下を追加すべきです。

    tests/hud-controller-normal-vocabulary.test.ts
    tests/canvas-text-boundary.test.ts
    tests/debug-raw-state-boundary.test.ts
    tests/e2e/ui-surface-boundary.spec.ts
    

    CSS や DOM result overlay に触るなら src/style.css も必要になります。現在の Allowed Paths のまま result overlay を Canvas から DOM へ移すのは、見た目・レイアウト面で Stop Condition を踏む可能性が高いです。

    4. debug panel の受け皿が未定義

    #1173 は raw state 出力を src/ui/playtestEvidence.ts または debug-only component に集約するとしています。しかし playtestEvidence.ts は ?playtest_evidence=1 の opt-in evidence panel で、metadata、viewport、DPR、artifact、runtime_state、deterministic_events、qualitative_notes を扱う証跡パネルです。通常 runtime の汎用 debug panel と同一視すると責務が混ざります。

    #987 / PR #1130 では evidence schema v2、deterministic events、qualitative notes、workflow-backed metadata まで整備されています。ここへ LoopPhase / raw telemetry を雑に足すと、playtest evidence payload と debug inspection surface が混線します。

    修正要求: #1173 は debug 受け皿を明確化する必要があります。

    5. #1174 との境界が危険

    #1174 は LoopPhase 遷移が ad-hoc な UI callback に分散していることを問題にし、PhaseTransitionSystem で一元管理する Issue です。#1173 は表示面の責務分離に限定すべきですが、HudController.ts や main.ts には phase gating / feedback / storage の意味論が絡んでいます。

    修正要求: #1173 は「phase transition behavior は変更しない」「button enable policy は既存維持」「phase mutation は #1174 に委譲」と明記すべきです。さもないと、raw enum 非表示の名目で phase control に触り始め、#1174 の責務と衝突します。

    望ましい契約修正

    最低限、#1173 の AC はこう直すべきです。

    ## Revised Acceptance Criteria
    
    - AC5: Normal HUD DOM textContent / accessible names MUST NOT contain forbidden normal-play vocabulary:
      - LoopPhase
      - Loop Phase
      - Telemetry
      - Claim reward
      - reward pending
      - title_menu
      - load_menu
      - debrief_pending_reward
      - debrief_reward_claimed
      - raw internal state name
      - raw command intent such as assist_player
      - fractional HP/HULL
      - <1
    
    - AC6: HudController may branch on LoopPhase values internally, but rendered normal UI must use player-facing copy only.
    
    - AC7: CanvasRenderer MUST NOT draw primary HUD/status/control/debug text via fillText.
      - stageLabel / elapsed timer must be moved to DOM HUD or removed from normal UI.
      - result outcome / duration / kills must have a DOM/menu overlay representation.
      - any remaining Canvas text must be explicitly whitelisted as non-authoritative world cue.
    
    - AC8: If enemy HP label remains in Canvas, it must be documented as a temporary non-authoritative world cue and covered by a boundary test.
      If it is removed, #788 tests and combat-core policy must be updated in the same PR or this Issue must stop.
    
    - AC9: raw LoopPhase / telemetry / exact values may appear only in an opt-in debug/evidence surface, never default-on normal UI.
    
    - AC10: viewport/zoom/DPR evidence must be captured for 1280x720, 1366x768, 1920x1080 and browser zoom 100%, 125%, 150%, 200%, with observed DPR, userAgent, screenshot path, and commit SHA.

    この修正は UI IA の viewport / DPR / evidence policy と整合します。UI IA は 1920x1080、1366x768、1280x720、100–200% zoom、DPR 1 / 1.25 / 2 を検証対象にしています。 WCAG 2.2 も 200% text resize と reflow を要求し、Microsoft の Xbox Accessibility Guidelines も PC/VR の game UI text に 1080p 換算 18px 以上を推奨しています。([W3C]3) ([W3C]3) ([Microsoft Learn]4)

    実装方針の推奨

    HudController.ts は raw GameState をそのまま DOM に投げるのではなく、normal UI 用 view model に投影してから描画するべきです。

    type NormalHudViewModel = {
      hull: string
      resources: string
      shots: string
      cooldown: string
      assistStatus: string
      playerStatus: string
      commandFeedback: string
      sortieSummary: string
      resultSummary: string
    }

    その上で、raw enum を扱う関数は内部純関数に閉じます。

    function toPlayerPhaseCopy(phase: LoopPhase): string {
      switch (phase) {
        case 'title_menu':
          return 'Ready to begin'
        case 'load_menu':
          return 'Choose saved progress'
        case 'preparation':
          return 'Prepare sortie'
        case 'running':
          return 'Sortie active'
        case 'result':
          return 'Sortie complete'
        case 'debrief_pending_reward':
        case 'debrief_reward_claimed':
          return 'Debrief'
      }
    }

    ただし、通常 HUD から Loop Phase という行自体を消すのが本筋です。phase copy を出すにしても、debug-style state inspection ではなく、menu/debrief/running のプレイヤー導線として表示すべきです。

    また、既存の role="status" / aria-live の使い方は残す価値があります。MDN は status role を advisory live region として説明し、暗黙に aria-live="polite" と aria-atomic="true" を持つとしています。([MDNウェブドキュメント]5) 現在の assist status と pause status はこの方向に沿っています。

    貼り付け用レビューコメント案

    REQUEST_CHANGES.
    
    #1173 の方向性は妥当ですが、現契約のままでは grep を満たすだけの浅い PR が通ります。
    
    Blocker 1:
    AC5 が "title_menu をそのまま DOM に出さない" だけになっていますが、通常 HUD には Loop Phase / Sortie Status / Telemetry / Claim reward が残っています。UI IA は LoopPhase, Telemetry, Claim reward, raw internal state name を normal play UI から排除する契約なので、render 後 DOM textContent / accessible name を対象に forbidden vocabulary を検証してください。
    
    Blocker 2:
    AC6 の "src/render に fillText がない" は過剰です。CanvasRenderer の HUD/result text だけでなく、renderUtils の enemy HP label も落ちます。enemy HP label を non-authoritative world cue として whitelist するのか、完全に廃止して #788 の tests/docs も更新するのかを Issue 契約で決めてください。
    
    Blocker 3:
    Allowed Paths に tests がありません。normal/debug vocabulary boundary、Canvas text boundary、debug-only raw telemetry boundary はテストで固定しないと再発します。tests/ と、必要なら src/style.css / src/main.ts を Allowed Paths に追加してください。
    
    Blocker 4:
    raw telemetry の移動先が playtestEvidence.ts なのか専用 debug component なのか曖昧です。playtestEvidence.ts は ?playtest_evidence=1 の opt-in evidence panel なので、汎用 debug panel と混線させるなら schema / export / gating の AC が必要です。
    
    この Issue は実装前に AC と Allowed Paths を再設計すべきです。

    最終結論

    #1173 は 必要な Issue ですが、現時点では 実装契約としては未成熟 です。特に AC5 は弱すぎ、AC6 は強すぎます。まず「通常 UI で forbidden vocabulary を出さない」「Canvas は primary HUD/control/debug text を描かない」「debug/evidence surface は opt-in で raw を隔離する」という検証可能な契約に差し替えるべきです。

  3. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  4. squne121 commented on Jun 30, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-30T23:04:33Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/1173
      body_sha256: "sha256:8c61611349557b22ac8131f7dac6654821bde21970ab255c41f73475e8a68b19"
      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/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions