Repository navigation
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1176"
goal_ref: "M4 Upgrade Loop の player-facing HUD purchase surface を追加し、購入可否と失敗理由を internal enum を漏らさず表示する"
change_kind: codeParent Issue
Parent Goal Ref
- Goal: preparation phase の HUD から upgrade 購入を操作でき、結果が player-facing copy と state 表示へ反映される
- Desired Destination: user が
ResourcesとWeapon Powerを見ながらUpgrade weaponaction を使える状態
Current Validated Scope
- 実装: src/data/upgrades.ts に M4 最小 UpgradeDefinition catalog を追加する #1280 / PR feat: add upgrade definition catalog #1292 により
src/data/upgrades.tsの M4 最小 catalog(weapon_power_plus_1: cost 100、effect.targetprogress.weaponPower、availability.phasepreparation、repeatable false)は merged 済み。 - 実装: UpgradeSystem で quote / atomic purchase / snapshot save を実装する #1281 / PR feat: add UpgradeSystem atomic purchase core (#1281) #1318 により
src/systems/UpgradeSystem.tsのquoteUpgrade()/purchaseUpgrade()とsrc/systems/PhaseTransitionSystem.tsのpurchase_upgrade(preparation -> preparationself-transition)は merged 済み。 purchaseUpgrade()は evaluate → candidateProgress/candidateSnapshot 構築 →storage.save()成功後にのみstate.progressを commit する atomic 設計であり、それ自体が atomic save seam である。src/ui/HudController.tsにはResources表示と既存 action buttons はあるが、Weapon Power表示・Upgrade weaponbutton・upgrade 用HudActionscallback はまだ無い。src/main.tsは upgrade 関連の import・handler を一切持たない。- 本 Issue 実装: HUD に upgrade purchase surface と player-facing state を追加する #1282 は catalog / purchase core を再実装せず、HUD view model と
main.tswiring のみを追加する。
Remaining Parent Gaps
- reload persistence / next-sortie reflection の runtime evidence は別 child issue
- Vite / GitHub Pages 配布境界(storage namespace / base path)は別 child issue(実装: M4 Upgrade Loop の E2E / preview evidence を追加する #1283)
Outcome
HUD と main loop wiring が更新され、preparation 中にのみ Upgrade weapon action が表示・操作可能となり、success / failure が player-facing copy と Resources / Weapon Power 表示へ反映される状態。
In Scope
HudControllerにWeapon Power表示とUpgrade weaponbutton を追加する- cost 表示と purchase status copy(success / failure reason 別)を追加する
src/main.tsで HUD action とquoteUpgrade()/purchaseUpgrade()を接続する- 購入成功後に
hasLoadableSnapshotをtrueに更新する - focused HUD / main loop test を追加する
Out of Scope
- upgrade definition catalog(
src/data/upgrades.ts、実装: src/data/upgrades.ts に M4 最小 UpgradeDefinition catalog を追加する #1280 で対応済み) - atomic purchase core 実装そのもの(
quoteUpgrade()/purchaseUpgrade()、実装: UpgradeSystem で quote / atomic purchase / snapshot save を実装する #1281 で対応済み) - E2E / preview namespace / reload persistence evidence
- Vite / GitHub Pages 配布境界(storage namespace / base path)は 実装: M4 Upgrade Loop の E2E / preview evidence を追加する #1283 の担当であり本 Issue のスコープ外
Acceptance Criteria
-
AC1: HUD に
Weapon Power表示が追加される -
AC2: HUD に
Upgrade weaponbutton と cost 表示が追加される。button 近傍の status copy 領域にはrole="status" aria-live="polite" aria-atomic="true"を持つ live region を使う -
AC3:
preparationかつquoteUpgrade()の結果が購入可能(ok: true相当)であり未購入のときだけ購入可能になる。HUD 側はstate.loopPhase === 'preparation'の独自判定を購入可否の正本にせず、quoteUpgrade()の結果を正本として扱う -
AC4:
quoteUpgrade()/purchaseUpgrade()の failure reason を以下のマッピングで player-facing copy に変換して表示する(internal enum 値そのものは表示しない)result HUD status HUD summary ok: true Upgrade installed. Weapon Power increased. Resources were saved. insufficient-resources Not enough resources. Earn 100 resources before upgrading. already-purchased Upgrade already installed. Weapon Power is already upgraded. not-preparation Upgrade available in hangar. Return to preparation before upgrading. write-error / storage-unavailable Upgrade not saved. No resources were spent. Check browser storage and try again. invalid-definition / invalid-state Upgrade unavailable. Current upgrade data could not be applied. -
AC5: raw
LoopPhase値・raw transition error・internalUpgradeFailureReason/UpgradePurchaseFailureReasonの enum 文字列そのものを通常 HUD の DOM textContent に表示しない -
AC6: purchase success 後、同一の同期
hud.render()呼び出し内(次のrequestAnimationFrameを待たない)でresourcesとweaponPower表示が更新され、かつhasLoadableSnapshotがtrueに更新される -
AC7:
pnpm typecheckが PASS する -
AC8:
pnpm lintが PASS する -
AC9:
pnpm testが PASS する -
AC10:
pnpm buildが PASS する
Verification Commands
# AC1
$ rg -n 'Weapon Power' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
# AC2
$ rg -n 'Upgrade weapon' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
# baseline-expect: pass
$ rg -n 'aria-live="polite"' src/ui/HudController.ts tests/hud-controller.test.ts
# AC3
$ rg -n 'quoteUpgrade' src/main.ts src/ui/HudController.ts tests/main-loop.test.ts tests/hud-controller.test.ts
# AC4
$ rg -n 'Upgrade installed\.' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
$ rg -n 'Not enough resources\.' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
$ rg -n 'Upgrade already installed\.' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
$ rg -n 'Upgrade not saved\.' src/ui/HudController.ts tests/hud-controller.test.ts tests/main-loop.test.ts
# AC5
# jsdom textContent アサーションで internal enum 値が漏れていないことを確認する(generic word の rg 一致では false-green になるため使わない)
# preflight-scope: pr_review_only
$ pnpm test -- tests/hud-controller.test.ts -t "does not leak internal upgrade failure reason"
# AC6
$ rg -n 'purchaseUpgrade' src/main.ts tests/main-loop.test.ts
# baseline-expect: pass
$ rg -n 'hasLoadableSnapshot' src/main.ts tests/main-loop.test.ts
# AC7
$ pnpm typecheck
# AC8
$ pnpm lint
# AC9
$ pnpm test
# AC10
$ pnpm buildAllowed Paths
- src/ui/HudController.ts
- src/main.ts
- tests/hud-controller.test.ts
- tests/main-loop.test.ts
Runtime Verification Applicability
- decision: not_applicable
- reason: 本 Issue は HUD / main loop wiring と unit-level verification で完結し、runtime / E2E evidence は後続 child issue に委譲する
Product Spec Context
source_of_truth: docs/product/features/upgrade.md
product_spec_id: DOC-UPGRADE-001
source_task_id: TASK-1176
requirement_id: REQ-1282
diff_rationale: "player-facing purchase surface が存在しないと M4 loop が UI から成立しないため、HUD 表示と操作面を追加する"
changed_requirement_id: DOC-UPGRADE-HUD-SURFACE
affected_sections:
- HUD purchase surface
- Player-facing failure copy
product_spec_change_mode: implementation_from_existing_product_specStop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- TypeScript
- DOM / UI controller
Required Design References
- docs/product/features/upgrade.md
- src/systems/UpgradeSystem.ts
- src/ui/HudController.ts
Delivery Rule
- 1 Issue = 1 PR
- 専用 worktree を使う
- child PR は
Closes #1282とRefs #1176を含める
Notes for Reviewer
- internal enum(
UpgradeFailureReason/UpgradePurchaseFailureReason/ rawLoopPhase)を user-facing text に漏らさず、copy は AC4 のマッピング表に従って通常 HUD 向けに限定する。 runProgressionSave()/persistProgressionSnapshot()を upgrade 購入成功パスで再利用・追加呼び出ししないこと。purchaseUpgrade()自体が atomic save seam であるため、成功時はhasLoadableSnapshot = trueと HUD feedback 更新のみでよい。- 実装方法の一例として、
main.tsでHudUpgradeViewModel { definitionId, label, cost, weaponPower, buttonDisabled, statusCopy }のような view model を作りHudController.render(state, isPaused, upgradeView)へ渡す設計を推奨するが、これは契約として強制はしない。 - atomic purchase の correctness 自体は別 child issue(実装: UpgradeSystem で quote / atomic purchase / snapshot save を実装する #1281、merge 済み)の責務であり、本 Issue では再検証しない。
- AC2 / AC6 の
aria-live="polite"/hasLoadableSnapshotVC は既存 baseline(assist-status / pause-status panel、既存 Save/Load Game 機能)で既に文字列一致するため# baseline-expect: passを付与している。これらの VC は実装有無ではなく「該当箇所が既存コードに存在し続けていること」の regression guard として扱う。 - AC5 の
pnpm test -- <file> -t "<name>"形式は preflight の pnpm allowlist(pnpm typecheck/pnpm lint/pnpm test/pnpm buildの exact 2-token 形式のみ許可)では実行できないため、# preflight-scope: pr_review_onlyを付与し baseline preflight では skip、実行と合否判定は PR review 時に委譲する。
Scope Delta(任意)
scope_cvs_in_scope_mismatch(non-blocking warning): Current Validated Scope は 実装: src/data/upgrades.ts に M4 最小 UpgradeDefinition catalog を追加する #1280 / 実装: UpgradeSystem で quote / atomic purchase / snapshot save を実装する #1281 で merge 済みの catalog / purchase core(前提条件)を記述し、In Scope は本 Issue で新規追加する HUD / main.ts wiring を記述するため、語彙的な重複が低くなるのは設計上の帰結である。CVS は「土台として使える既存実装が何か」を示す節であり、In Scope は「その土台の上に何を新規追加するか」を示す節であるため、意図的に語彙を分けている。
Activity
squne121 commentedon Jul 6, 2026
判定
REQUEST_CHANGES 相当。#1282 の方向性は妥当ですが、実装指示としては stale です。
#1282 は open / コメント0件で、HUD に
Weapon Power、Upgrade weapon、cost、購入結果 copy、main.tswiring を追加する child Issue です。ただし本文の「purchase core は別 child issue で実装予定」という前提は、現在の repo reality では古いです。#1280 は PR #1292 で merged、#1281 は PR #1318 で merged 済みなので、#1282 は 新規ロジック実装ではなく、既存 catalog / UpgradeSystem を HUD に安全に接続する Issue として再定義すべきです。確認した範囲では、#1282 を直接 close する実装 PR は見当たらず、検索結果は先行 child の #1292 / #1318 参照に留まっています。つまり、現時点の本体実装では HUD surface は未実装のままと見てよいです。
現在の repo reality
src/data/upgrades.tsにはweapon_power_plus_1、cost: 100、effect.target: 'progress.weaponPower'、value: 1、availability.phase: 'preparation'、repeatable: falseの M4 最小 catalog が既に存在します。UpgradeSystem側も既にquoteUpgrade/purchaseUpgrade、failure reason union、構造化 quote payload を持っています。特にpurchaseUpgradeは candidate progress / candidate snapshot を作り、storage.save()が成功してからstate.progressを commit する設計になっています。これは #1282 が必ず使うべき既存 seam です。purchase_upgradeintent もPhaseTransitionSystemに追加済みで、preparation -> preparationの self-transition として登録されています。HUD 側で独自にstate.loopPhase === 'preparation'だけを見るのではなく、最低でもquoteUpgradeの結果を購入可否の正本にすべきです。一方、現在の
HudActionsには upgrade callback がなく、Progress panel もHull / Resources / Shots / CooldownのみでWeapon Powerはありません。Action panel にもUpgrade weaponbutton はありません。main.tsもupgradeDefinitions/quoteUpgrade/purchaseUpgradeを import しておらず、createHudControllerへ渡す action 群にも upgrade handler がありません。P0 ブロッカー
1. #1282 の依存前提を更新しないと、実装者が core を再実装する
#1282 の本文は「systems 層の purchase core は別 child issue で実装予定」と読めますが、現在は #1281 / PR #1318 が merged され、
UpgradeSystemはsrc/systems/index.tsから export 済みです。#1282 はこの core を直接 consume する契約に直すべきです。修正文言は以下の方向が妥当です。
2.
runProgressionSave()を purchase 用に再利用してはいけないrunProgressionSave()は現在の live state から snapshot を作って保存し、HUD feedback を返す汎用保存 seam です。しかし upgrade spec は
validate → debit → apply → snapshotと、保存成功後のみ livestate.progressを commit する strong atomic visible success を要求しています。したがって #1282 の
main.tswiring は、購入成功 path でpersistProgressionSnapshot()/runProgressionSave()を追加呼び出ししないことを明記すべきです。purchaseUpgrade(state, 'weapon_power_plus_1', definition, storage)が保存まで責任を持つため、成功時はhasLoadableSnapshot = trueと HUD feedback 更新だけでよいです。3. failure reason をそのまま HUD に出す危険がある
#1282 は
insufficient resources/already purchased/save failure/ success を player-facing copy にするとしていますが、実際のUpgradeSystemはinvalid-definition、invalid-state、not-preparation、write-error、storage-unavailableなどの internal reason を返します。これらをそのまま HUD に出すと、#1282 AC5 の「internal enum を通常 HUD に表示しない」に違反します。推奨 mapping は以下です。
purchaseUpgrade result | HUD status | HUD summary -- | -- | -- ok: true | Upgrade installed. | Weapon Power increased. Resources were saved. insufficient-resources | Not enough resources. | Earn 100 resources before upgrading. already-purchased | Upgrade already installed. | Weapon Power is already upgraded. not-preparation | Upgrade available in hangar. | Return to preparation before upgrading. write-error / storage-unavailable | Upgrade not saved. | No resources were spent. Check browser storage and try again. invalid-definition / invalid-state | Upgrade unavailable. | Current upgrade data could not be applied.特に storage failure では「購入できた」ニュアンスを出してはいけません。MDN は
localStorageが origin 単位で保存され、SecurityErrorが発生し得ること、file:URL の挙動に依存すべきでないことを明記しています。またStorage.setItem()は quota 等でQuotaExceededErrorを投げ得ます。(MDNウェブドキュメント)4. AC3 の購入可否判定を HUD 内に複製すると drift する
#1282 は「
preparationかつresources >= costかつ未購入のときだけ購入可能」としています。これは見た目だけならstate.loopPhase/state.progress.resources/state.progress.weaponPowerで判定できますが、現在の正本はquoteUpgrade()です。quoteUpgrade()は malformed definition、invalid state、phase gate、already purchased、insufficient resources、overflow まで判定しています。敵対的には、
HudControllerに business rule を重複実装させず、main.tsでquoteUpgrade()から view model を作る設計が安全です。HudController.render(state, isPaused, upgradeView)のように渡せば、HUD は DOM 表示に専念できます。Allowed Paths はHudController.ts/main.ts/ tests なので、この変更は #1282 の範囲内で収まります。5. 「same render tick」AC6 が現在の実装では曖昧
現在の frame loop は毎フレーム
hud.render(state, productPause.isPaused)を呼びます。購入 handler が state を即時更新しても、DOM が同じ JS event tick で更新されるとは限りません。次の animation frame で表示されるだけなら、AC6 の「同一 render tick」の解釈が曖昧になります。
#1282 では次のどちらかに固定すべきです。
DOM 即時更新契約: purchase success handler の最後で
hud.render(state, productPause.isPaused, buildUpgradeView())を同期呼び出しする。次 render 呼び出し契約: handler success 後、次の
HudController.render()でresourcesとweaponPowerが同時に反映されることを unit test で保証する。Issue 文の AC6 は「同一 render tick」と書いているので、1 の方が仕様に忠実です。ただし実装負荷を下げるなら、AC6 を「同一
HudController.render()呼び出し内でResourcesとWeapon Powerが同時更新される」に書き換えるべきです。P1 高リスク指摘
6.
hasLoadableSnapshot更新を忘れると、購入直後に Load Game が false-negative になるmain.tsは startup probe の結果をhasLoadableSnapshotに保持し、Load Game button の有効化に使っています。purchaseUpgrade()は storage save まで行うため、成功時にはhasLoadableSnapshot = trueに更新しないと、購入後に保存済みなのに Load Game が使えない UI になります。7. accessibility の状態通知を upgrade 専用に切るべき
現 HUD には
Pilot updatesの status live region があり、assist status にはaria-live="polite"とaria-atomic="true"が付いています。upgrade の成否も同様に、button 近傍へrole="status" aria-live="polite" aria-atomic="true"を持つ status copy を置くべきです。WAI-ARIA は accessible name には見えるテキストを優先する考え方を示しており、MDN も live region は動的な変更を支援技術へ通知するため、変更前に
aria-liveなどを付けておく必要があると説明しています。role="status"には互換性のためaria-live="polite"を重ねるのが実務上安全です。(W3C)8. Vite / GitHub Pages 側の配布境界は #1282 で触らない
#1282 は HUD / main loop wiring なので、storage namespace や Pages base path に触るべきではありません。#1283 が E2E / preview namespace evidence を担当しています。
Vite の GitHub Pages 配布では repo 配下公開時に
base: '/<REPO>/'が必要で、VITE_*env は client bundle に露出します。VITE_LOOP_STORAGE_NAMESPACEのような非秘密 namespace 以外を入れてはいけません。#1282 の実装者が storage namespace を UI 都合で変更するのは scope creep です。(vitejs)P2 改善提案
9. Verification command の
rgは false-red / false-green を起こす#1282 の AC4 は
rg -n 'insufficient resources'のような文字列検索になっていますが、上記のように HUD copy はNot enough resources.の方が自然です。逆に internal reason のinsufficient-resourcesを出す実装でも grep を通せてしまう可能性があります。修正案:
既存テストには、HUD text surface に
title_menu/load_menu/illegal-transitionなどの raw vocabulary が出ないことを確認する境界テストがあります。#1282 ではここへinvalid-definition、invalid-state、write-error、storage-unavailable、purchase_upgradeを追加するのがよいです。10.
LoopPhaseのrg禁止は雑すぎる#1282 の AC5 verification は
rg -n 'LoopPhase' src/ui/HudController.ts ...になっていますが、型 import や test helper でLoopPhaseを使うこと自体は問題ではありません。問題は 通常 HUD の textContent に raw phase / transition error / internal reason が出ること です。そのため
rgよりも jsdom test で以下を見た方が正確です。#1282 に追加すべき実装契約
最小差分としては以下です。
HudActionsにonUpgradeWeapon(): voidを追加する。HUD Progress に
Weapon Powerfield を追加する。Upgrade panel または Action panel に
Upgrade weaponbutton、Cost: 100 resources、status copy を追加する。main.tsでupgradeDefinitions[0]を選び、quoteUpgrade()から HUD view model を作る。click handler は
purchaseUpgrade()だけを purchase save seam として使う。success 時は
hasLoadableSnapshot = true、player-facing feedback を設定し、必要なら同期hud.render()で DOM を即時更新する。failure reason はすべて copy mapping し、raw reason を HUD に出さない。
tests/hud-controller.test.tsで DOM surface / disabled policy / internal vocabulary boundary を検証する。tests/main-loop.test.tsで purchase handler seam を検証する。推奨する
main.tstest seam は以下の形です。tests/main-loop.test.tsは現時点で upgrade seam を import していないため、この追加が #1282 の中心になります。最終レビューコメント案
検証コマンドは今回こちらでは未実行です。上記は GitHub connector と Web 仕様確認に基づく静的・敵対的レビューです。
## 判定REQUEST_CHANGES 相当。#1282 の方向性は妥当ですが、実装指示としては stale です。
#1282 は open / コメント0件で、HUD に
Weapon Power、Upgrade weapon、cost、購入結果 copy、main.tswiring を追加する child Issue です。ただし本文の「purchase core は別 child issue で実装予定」という前提は、現在の repo reality では古いです。#1280 は PR #1292 で merged、#1281 は PR #1318 で merged 済みなので、#1282 は 新規ロジック実装ではなく、既存 catalog / UpgradeSystem を HUD に安全に接続する Issue として再定義すべきです。確認した範囲では、#1282 を直接 close する実装 PR は見当たらず、検索結果は先行 child の #1292 / #1318 参照に留まっています。つまり、現時点の本体実装では HUD surface は未実装のままと見てよいです。
現在の repo reality
src/data/upgrades.tsにはweapon_power_plus_1、cost: 100、effect.target: 'progress.weaponPower'、value: 1、availability.phase: 'preparation'、repeatable: falseの M4 最小 catalog が既に存在します。UpgradeSystem側も既にquoteUpgrade/purchaseUpgrade、failure reason union、構造化 quote payload を持っています。特にpurchaseUpgradeは candidate progress / candidate snapshot を作り、storage.save()が成功してからstate.progressを commit する設計になっています。これは #1282 が必ず使うべき既存 seam です。purchase_upgradeintent もPhaseTransitionSystemに追加済みで、preparation -> preparationの self-transition として登録されています。HUD 側で独自にstate.loopPhase === 'preparation'だけを見るのではなく、最低でもquoteUpgradeの結果を購入可否の正本にすべきです。一方、現在の
HudActionsには upgrade callback がなく、Progress panel もHull / Resources / Shots / CooldownのみでWeapon Powerはありません。Action panel にもUpgrade weaponbutton はありません。main.tsもupgradeDefinitions/quoteUpgrade/purchaseUpgradeを import しておらず、createHudControllerへ渡す action 群にも upgrade handler がありません。P0 ブロッカー
1. #1282 の依存前提を更新しないと、実装者が core を再実装する
#1282 の本文は「systems 層の purchase core は別 child issue で実装予定」と読めますが、現在は #1281 / PR #1318 が merged され、
UpgradeSystemはsrc/systems/index.tsから export 済みです。#1282 はこの core を直接 consume する契約に直すべきです。修正文言は以下の方向が妥当です。
2.
runProgressionSave()を purchase 用に再利用してはいけないrunProgressionSave()は現在の live state から snapshot を作って保存し、HUD feedback を返す汎用保存 seam です。しかし upgrade spec は
validate → debit → apply → snapshotと、保存成功後のみ livestate.progressを commit する strong atomic visible success を要求しています。したがって #1282 の
main.tswiring は、購入成功 path でpersistProgressionSnapshot()/runProgressionSave()を追加呼び出ししないことを明記すべきです。purchaseUpgrade(state, 'weapon_power_plus_1', definition, storage)が保存まで責任を持つため、成功時はhasLoadableSnapshot = trueと HUD feedback 更新だけでよいです。3. failure reason をそのまま HUD に出す危険がある
#1282 は
insufficient resources/already purchased/save failure/ success を player-facing copy にするとしていますが、実際のUpgradeSystemはinvalid-definition、invalid-state、not-preparation、write-error、storage-unavailableなどの internal reason を返します。これらをそのまま HUD に出すと、#1282 AC5 の「internal enum を通常 HUD に表示しない」に違反します。推奨 mapping は以下です。
purchaseUpgraderesultok: trueUpgrade installed.Weapon Power increased. Resources were saved.insufficient-resourcesNot enough resources.Earn 100 resources before upgrading.already-purchasedUpgrade already installed.Weapon Power is already upgraded.not-preparationUpgrade available in hangar.Return to preparation before upgrading.write-error/storage-unavailableUpgrade not saved.No resources were spent. Check browser storage and try again.invalid-definition/invalid-stateUpgrade unavailable.Current upgrade data could not be applied.特に storage failure では「購入できた」ニュアンスを出してはいけません。MDN は
localStorageが origin 単位で保存され、SecurityErrorが発生し得ること、file:URL の挙動に依存すべきでないことを明記しています。またStorage.setItem()は quota 等でQuotaExceededErrorを投げ得ます。([MDNウェブドキュメント]1)4. AC3 の購入可否判定を HUD 内に複製すると drift する
#1282 は「
preparationかつresources >= costかつ未購入のときだけ購入可能」としています。これは見た目だけならstate.loopPhase/state.progress.resources/state.progress.weaponPowerで判定できますが、現在の正本はquoteUpgrade()です。quoteUpgrade()は malformed definition、invalid state、phase gate、already purchased、insufficient resources、overflow まで判定しています。敵対的には、
HudControllerに business rule を重複実装させず、main.tsでquoteUpgrade()から view model を作る設計が安全です。HudController.render(state, isPaused, upgradeView)のように渡せば、HUD は DOM 表示に専念できます。Allowed Paths はHudController.ts/main.ts/ tests なので、この変更は #1282 の範囲内で収まります。5. 「same render tick」AC6 が現在の実装では曖昧
現在の frame loop は毎フレーム
hud.render(state, productPause.isPaused)を呼びます。購入 handler が state を即時更新しても、DOM が同じ JS event tick で更新されるとは限りません。次の animation frame で表示されるだけなら、AC6 の「同一 render tick」の解釈が曖昧になります。
#1282 では次のどちらかに固定すべきです。
hud.render(state, productPause.isPaused, buildUpgradeView())を同期呼び出しする。HudController.render()でresourcesとweaponPowerが同時に反映されることを unit test で保証する。Issue 文の AC6 は「同一 render tick」と書いているので、1 の方が仕様に忠実です。ただし実装負荷を下げるなら、AC6 を「同一
HudController.render()呼び出し内でResourcesとWeapon Powerが同時更新される」に書き換えるべきです。P1 高リスク指摘
6.
hasLoadableSnapshot更新を忘れると、購入直後に Load Game が false-negative になるmain.tsは startup probe の結果をhasLoadableSnapshotに保持し、Load Game button の有効化に使っています。purchaseUpgrade()は storage save まで行うため、成功時にはhasLoadableSnapshot = trueに更新しないと、購入後に保存済みなのに Load Game が使えない UI になります。7. accessibility の状態通知を upgrade 専用に切るべき
現 HUD には
Pilot updatesの status live region があり、assist status にはaria-live="polite"とaria-atomic="true"が付いています。upgrade の成否も同様に、button 近傍へrole="status" aria-live="polite" aria-atomic="true"を持つ status copy を置くべきです。WAI-ARIA は accessible name には見えるテキストを優先する考え方を示しており、MDN も live region は動的な変更を支援技術へ通知するため、変更前に
aria-liveなどを付けておく必要があると説明しています。role="status"には互換性のためaria-live="polite"を重ねるのが実務上安全です。([W3C]2)8. Vite / GitHub Pages 側の配布境界は #1282 で触らない
#1282 は HUD / main loop wiring なので、storage namespace や Pages base path に触るべきではありません。#1283 が E2E / preview namespace evidence を担当しています。
Vite の GitHub Pages 配布では repo 配下公開時に
base: '/<REPO>/'が必要で、VITE_*env は client bundle に露出します。VITE_LOOP_STORAGE_NAMESPACEのような非秘密 namespace 以外を入れてはいけません。#1282 の実装者が storage namespace を UI 都合で変更するのは scope creep です。([vitejs]3)P2 改善提案
9. Verification command の
rgは false-red / false-green を起こす#1282 の AC4 は
rg -n 'insufficient resources'のような文字列検索になっていますが、上記のように HUD copy はNot enough resources.の方が自然です。逆に internal reason のinsufficient-resourcesを出す実装でも grep を通せてしまう可能性があります。修正案:
既存テストには、HUD text surface に
title_menu/load_menu/illegal-transitionなどの raw vocabulary が出ないことを確認する境界テストがあります。#1282 ではここへinvalid-definition、invalid-state、write-error、storage-unavailable、purchase_upgradeを追加するのがよいです。10.
LoopPhaseのrg禁止は雑すぎる#1282 の AC5 verification は
rg -n 'LoopPhase' src/ui/HudController.ts ...になっていますが、型 import や test helper でLoopPhaseを使うこと自体は問題ではありません。問題は 通常 HUD の textContent に raw phase / transition error / internal reason が出ること です。そのため
rgよりも jsdom test で以下を見た方が正確です。#1282 に追加すべき実装契約
最小差分としては以下です。
HudActionsにonUpgradeWeapon(): voidを追加する。Weapon Powerfield を追加する。Upgrade weaponbutton、Cost: 100 resources、status copy を追加する。main.tsでupgradeDefinitions[0]を選び、quoteUpgrade()から HUD view model を作る。purchaseUpgrade()だけを purchase save seam として使う。hasLoadableSnapshot = true、player-facing feedback を設定し、必要なら同期hud.render()で DOM を即時更新する。tests/hud-controller.test.tsで DOM surface / disabled policy / internal vocabulary boundary を検証する。tests/main-loop.test.tsで purchase handler seam を検証する。推奨する
main.tstest seam は以下の形です。tests/main-loop.test.tsは現時点で upgrade seam を import していないため、この追加が #1282 の中心になります。最終レビューコメント案
検証コマンドは今回こちらでは未実行です。上記は GitHub connector と Web 仕様確認に基づく静的・敵対的レビューです。
squne121 commentedon Jul 6, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jul 7, 2026
Contract Review Result
squne121 commentedon Jul 7, 2026
implement-issue: 実装完了
.claude/worktrees/issue-1282-hud-upgrade-purchase-surface-player-faciworktree-issue-1282-hud-upgrade-purchase-surface-player-facifix: Weapon PowerとArmoryパネルの追加によるHUDレイアウトreflowを解消する (#1282 fix_delta)
fix: AC6 hasLoadableSnapshot を render 前に確定させる seam に変更する (#1282 fix_d…
feat: HUDにupgrade purchase surfaceとplayer-facing stateを追加する (#1365)