Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Milestone
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "#1176"
goal_ref: "M4 Upgrade Loop の upgrade definition catalog を armament seed とは別の pure data 実体として追加し、後続の purchase / HUD / E2E child issue が参照できる状態にする"
change_kind: dataParent Issue
Parent Goal Ref
- Goal: M4 Upgrade Loop の close 条件に必要な upgrade definition を weapon/unit seed と分離して実体化する
- Desired Destination:
docs/product/features/upgrade.mdの最小 M4 spec に一致する UpgradeDefinition catalog がsrc/data/upgrades.tsに存在する状態
Current Validated Scope
docs/product/features/upgrade.mdにはweapon_power_plus_1/currency: resources/cost: 100/target: progress.weaponPower/operation: add/value: 1/preparation限定 /repeatable: falseが規定済みsrc/data/weapons.ts/src/data/units.tsは armament seed のみで upgrade definition ではないsrc/data/CLAUDE.mdは data file に helper 関数や制御フローを置かない invariant を持つsrc/data/index.tsは現時点で存在せず、本 Issue では barrel export を新設しない
Remaining Parent Gaps
- quote / validation / atomic purchase / snapshot save は別 child issue
- HUD purchase surface と player-facing copy は別 child issue
- reload persistence と next-sortie reflection の runtime evidence は別 child issue
Shape Decision
- TypeScript catalog は repo 既存 data convention に合わせて
definitionIdを使う - product spec 上の
upgrade_id: weapon_power_plus_1は TypeScript 実装ではdefinitionId: 'weapon_power_plus_1'に対応する - product spec 上の
upgrade_definition_schema_version: 1は TypeScript 実装ではschemaVersion: 1に対応する target/operation/valueはeffectobject 配下に置く- 後続 consumer は
src/data/upgrades.tsを直接 import する
Outcome
src/data/upgrades.ts と tests/upgrade-definitions.test.ts が追加され、M4 最小 UpgradeDefinition catalog が pure data enumeration と focused test として repo に存在し、後続 child issue が同 catalog を正本として参照できる状態。
In Scope
src/data/upgrades.tsを新規追加するUpgradeDefinitionとupgradeDefinitionsを最小 catalog surface として定義するdefinitionId: 'weapon_power_plus_1'を持つ M4 最小 entry を data 実体化する- catalog shape と invariant を確認する focused test を追加する
Out of Scope
- upgrade 購入ロジック、resource debit、snapshot save
purchase_upgradeintent や phase transition- HUD 表示、button wiring、player-facing copy
- E2E / runtime evidence
src/data/index.tsの新設や barrel export 整備
Acceptance Criteria
- AC1:
src/data/upgrades.tsが追加される - AC2: catalog entry は
definitionId: 'weapon_power_plus_1'を持つ - AC3: catalog entry は
schemaVersion: 1を持ち、product spec 上のupgrade_definition_schema_version: 1に対応する - AC4: catalog entry は
currency: 'resources'とcost: 100を持つ - AC5: catalog entry は
effect.target: 'progress.weaponPower'を持つ - AC6: catalog entry は
effect.operation: 'add'とeffect.value: 1を持つ - AC7: catalog entry は
availability.phase: 'preparation'とavailability.repeatable: falseを持つ - AC8: catalog は
as const satisfies readonly UpgradeDefinition[]を使う - AC9:
tests/upgrade-definitions.test.tsが catalog size、exact object shape、definitionId uniqueness を検証する - AC10:
pnpm typecheckが PASS する - AC11:
pnpm lintが PASS する - AC12:
pnpm testが PASS する - AC13:
pnpm buildが PASS する
Verification Commands
# AC1
# baseline-expect: fail
$ test -f src/data/upgrades.ts
# AC2
# preflight-scope: pr_review_only
$ rg -n "definitionId: 'weapon_power_plus_1'" src/data/upgrades.ts
# AC3
# preflight-scope: pr_review_only
$ rg -n "schemaVersion: 1" src/data/upgrades.ts
# AC4
# preflight-scope: pr_review_only
$ rg -n "currency: 'resources'" src/data/upgrades.ts
# preflight-scope: pr_review_only
$ rg -n "cost: 100" src/data/upgrades.ts
# AC5
# preflight-scope: pr_review_only
$ rg -n "target: 'progress\\.weaponPower'" src/data/upgrades.ts
# AC6
# preflight-scope: pr_review_only
$ rg -n "operation: 'add'" src/data/upgrades.ts
# preflight-scope: pr_review_only
$ rg -n "value: 1" src/data/upgrades.ts
# AC7
# preflight-scope: pr_review_only
$ rg -n "phase: 'preparation'" src/data/upgrades.ts
# preflight-scope: pr_review_only
$ rg -n "repeatable: false" src/data/upgrades.ts
# AC8
# preflight-scope: pr_review_only
$ rg -n "as const satisfies readonly UpgradeDefinition\\[]" src/data/upgrades.ts
# AC9
# preflight-scope: pr_review_only
$ rg -n "toHaveLength\\(1\\)" tests/upgrade-definitions.test.ts
# preflight-scope: pr_review_only
$ rg -n "toEqual\\(" tests/upgrade-definitions.test.ts
# preflight-scope: pr_review_only
$ rg -n "new Set\\(" tests/upgrade-definitions.test.ts
# AC10
$ pnpm typecheck
# AC11
$ pnpm lint
# AC12
$ pnpm test
# AC13
$ pnpm buildAllowed Paths
- src/data/upgrades.ts
- tests/upgrade-definitions.test.ts
Runtime Verification Applicability
- decision: not_applicable
- reason: 本 Issue は static data catalog と focused unit test の追加で完結し、runtime verification は後続 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-M4-UPGRADE-CATALOG
diff_rationale: "M4 close 条件に必要な upgrade definition は armament seed と別実体であるため、spec 既定値を src/data/upgrades.ts に materialize する"
changed_requirement_id: DOC-UPGRADE-MINIMAL-CATALOG
affected_sections:
- Upgrade Definition Schema
product_spec_change_mode: implementation_from_existing_product_specStop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- TypeScript
- Vitest
Delivery Rule
- 1 Issue = 1 PR
- 専用 worktree を使う
- child PR は
Closes #<child>とRefs #1176を含める
Notes for Reviewer
src/data/weapons.ts / src/data/units.ts の armament seed を upgrade definition 完了と誤認しないこと。catalog は pure data のみとし、ロジックは別 Issue の purchase / apply 系 child に送る。
Scope Delta(任意)
N/A
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phase
Activity
squne121 commentedon Jul 2, 2026
判定
#1280 は方向性は妥当。ただし、このまま実装指示として渡すと false-red / false-green の両方を起こす余地があります。
特に問題なのは、Issue本文の verification command が TypeScript 実装形と噛み合っていない点、
UpgradeDefinitionのキー命名が spec のupgrade_id/upgrade_definition_schema_versionと repo 既存のdefinitionId慣習の間で曖昧な点、src/data/index.tsが存在しない可能性を “必要なら export” として曖昧にしている点です。#1280 自体はコメントなしです。 直接の #1280 PR も見当たらず、実装前レビュー対象として扱うのが妥当です。
参照した主な文脈
#1280 は、親 #1176 の child issue で、
src/data/upgrades.tsにweapon_power_plus_1を pure data catalog として追加し、src/data/weapons.ts/src/data/units.tsを upgrade definition と誤認しないことを明示しています。 これは #1279 が広すぎるため、upgrade catalog / atomic purchase / HUD / E2E evidence の4分割に切り替えられた流れと整合します。正本 spec である
docs/product/features/upgrade.mdは、M4最小 upgrade をweapon_power_plus_1、currency: resources、cost: 100、target: progress.weaponPower、operation: add、value: 1、availability.phase: preparation、repeatable: falseとして定義しています。 また、repeatable: falseは M4 ではstate.progress.weaponPower > 1で購入済み判定し、purchasedUpgradeIdsのような ledger は導入しない、と明記されています。既存 data 層の不変条件は「ロジック、if / while / 関数本体を含まない」「1ファイル1ドメイン」「バランス調整は数値変更のみ」です。 既存
weapons.ts/units.tsはdefinitionIdベースの readonly catalog で、as const satisfies readonly ...[]形式を採っています。 PR #1263 も weapon/unit catalog は armament seed であり、runtime consumer や docs/tests には触れていないと説明しています。P0 / ブロッカー
1. Verification command が TypeScript 実装形と一致していない
#1280 の検証コマンドには、たとえば次のような grep が含まれています。
しかし TypeScript の実装は通常こうなります。
つまり、正しく実装しても
currency: resources/target: progress.weaponPower/operation: addは quote なしなので fail します。これは CI ではなく reviewer 用 command でも有害です。実装者が grep を通すために不正な TypeScript へ寄せる、または検証を無視する、という両方の事故が起きます。修正すべき command:
2.
upgrade_idとdefinitionIdの authority が曖昧spec は YAML 上で
upgrade_idとupgrade_definition_schema_versionを使っています。 一方、repo の data catalog はWeaponDefinition/UnitDefinitionともにdefinitionIdを採用しています。#1280 は
weapon_power_plus_1を含むとは書いていますが、TypeScript interface のフィールド名を明示していません。ここを曖昧にすると、実装者が次のどちらかを勝手に選びます。upgradeId: 'weapon_power_plus_1'または
definitionId: 'weapon_power_plus_1'敵対的には、repo 既存の data convention に合わせて
definitionIdを採用し、spec との対応はコメントではなく issue AC に明記すべきです。upgrade_idは product spec の YAML 表現、definitionIdは TypeScript data catalog の repository convention、という境界を固定してください。推奨修正:
3.
src/data/index.tsは存在しない可能性が高く、Allowed Paths に入れるだけでは危険src/data/index.tsを fetch すると 404 でした。既存src/state/index.tsやsrc/systems/index.tsには barrel export がありますが、src/data/index.tsは現 repo 上には確認できません。#1280 は「必要なら
src/data/index.tsに export」としていますが、存在しない barrel をこのIssueで新設してよいのかが曖昧です。src/data/CLAUDE.mdは 1ファイル1ドメインを要求しており、barrel 追加は “domain data file” ではなく module surface 変更です。推奨はどちらかに固定です。
#1280 の narrow scope を守るなら Option A が安全です。
P1 / 高リスク指摘
4. AC5 が “helper 関数なし” を要求しているのに、test の方向が弱い
#1280 は
src/data/CLAUDE.mdの invariant に従い、helper 関数や制御フローを含まない pure data enumeration を要求しています。 ただし検証はrg -n 'weapon_power_plus_1' tests/upgrade-definitions.test.ts程度で、helper 関数がないことを保証しません。最低限、テストでは値の完全一致と catalog size を見るべきです。Vitest の
toEqualは object の構造を再帰比較する matcher なので、この用途に合います。([vitest.dev]1)推奨 test:
5.
as const satisfies readonly UpgradeDefinition[]は正しいが、何を防ぐのかをIssueが説明していないこの要求自体は良いです。TypeScript の
satisfiesは、式が型に合うことを検証しつつ、式のより具体的な推論型を保持します。(TypeScript)as constは literal widening を防ぎ、object literal を readonly、array literal を readonly tuple にします。([TypeScript]3)したがって #1280 の実装は、次の形が妥当です。
ただし、
costとvalueをnumberにするか、100/1literal にするかは意図を分けるべきです。catalog consumer が将来 balance tuning を読むなら interface はnumber、M4 最小 catalog のテストは100/1exact match、が良いです。6. Runtime / persistence の話を #1280 に混ぜないのは正しいが、後続 issue への接続はもう少し硬くすべき
#1281 は
quoteUpgrade/ atomic purchase / save 成功後 commit を担当します。 #1282 は HUD surface、#1283 は E2E / preview evidence を担当します。 この分割は妥当です。ただし #1280 の catalog shape が後続 issue の import contract になります。よって #1280 側に次の AC を追加すべきです。
これにより #1280 が “小さいが後続に使えない静的ファイル” で終わる事故を防げます。
P2 / 改善提案
7.
schemaVersionの命名を固定するspec は
upgrade_definition_schema_versionですが、TypeScript 実装ではschemaVersion: 1が自然です。gameSnapshotSchemaVersionも state 側に存在します。推奨:
upgradeDefinitionSchemaVersionという exported const を別に置く案もありますが、src/data/CLAUDE.mdの “pure data enumeration” から見ると余計です。#1280 では literalschemaVersion: 1で十分です。8.
effectobject を入れるべき#1280 の本文は
target/operation/valueを flat field としても読めます。一方、親コメントや spec の apply contract は “effect” として扱うのが自然です。flat にすると将来availabilityと同じ階層に operation 系が散らばります。推奨 shape:
理由は、#1281 の validation / apply が
definition.effectを処理でき、HUD はdefinition.cost/definition.availabilityを読むだけで済むためです。9. catalog file にコメントを入れすぎない
src/data/CLAUDE.mdは pure data enumeration を求めています。 長い comment block で spec の再説明を入れると、後続 agent が “ここに validation rationale を追加してよい” と誤解します。許容するなら短い1行だけです。
// M4 minimal upgrade catalog. Runtime purchase semantics live in UpgradeSystem.ただし、最も安全なのはコメントなしです。
外部仕様・配布物観点での補強
#1280 自体は static data catalog なので localStorage / GitHub Pages / Vite distribution を直接扱う必要はありません。ただし、M4全体では配布物品質に影響します。
Vite の GitHub Pages 配布では、
https://<USERNAME>.github.io/<REPO>/形式ならbaseを/<REPO>/に設定する必要があります。また Vite は build step が必要なため、GitHub Actions 経由の Pages deployment が公式に案内されています。([vitejs]4) Vite のVITE_*env は client bundle に露出するため、VITE_LOOP_STORAGE_NAMESPACEのような非秘密 namespace 以外を入れるべきではありません。([vitejs]5)localStorage は origin 単位で保存され、
file:/data:scheme や永続化拒否設定ではSecurityErrorが起こり得ます。([MDN Web Docs]6)Storage.setItem()は quota 不足やユーザー拒否でQuotaExceededErrorを投げ得ます。([MDN Web Docs]7) WHATWG HTML Standard も localStorage について locking mechanism がない前提を明記しているため、M4の atomicity は #1281 のように単一 runtime 内の save-before-visible-success へ限定するのが正しいです。([HTML Living Standard]8)この観点からも、#1280 に storage / save / rollback を混ぜない判断は正しいです。storage failure model は #1281 / #1283 に残すべきです。
#1280 本文への具体的な修正案
そのまま貼れる粒度で直すなら、以下を追加・変更してください。
最終コメント
#1280 は分割後の first child としては必要です。ただし現状のままでは、grep 検証の quote 不一致とfield naming の曖昧さが実装品質を落とします。修正後の #1280 は “catalog を追加するだけ” に徹し、#1281 の atomic purchase、#1282 の HUD、#1283 の runtime evidence に責務を渡すのが最も堅いです。
squne121 commentedon Jul 2, 2026
Contract Review Result
squne121 commentedon Jul 2, 2026
implement-issue: 実装完了 (2026-07-02T12:59:33Z)
.claude/worktrees/issue-1280-src-data-upgrades-ts-m4-upgradedefinitioworktree-issue-1280-src-data-upgrades-ts-m4-upgradedefinitiopnpm typecheck/pnpm lint/pnpm test/pnpm build= PASSrg -Pn "(?s)...系 review-only command は localrg挙動では multiline object を拾わず 0 件でしたpr-review-judge→ 人間レビュー → マージ →post-merge-cleanupsqune121 commentedon Jul 2, 2026
Contract Review Result
feat: add upgrade definition catalog (#1280) (#1292)