Skip to content

feat(data): bootstrap armament catalogs - #1263

Merged
squne121 merged 4 commits into
mainfrom
worktree-issue-1175-src-data-weapons-ts-src-data-units-ts-ar
Jul 1, 2026
Merged

squne121 merged 4 commits into
mainfrom
worktree-issue-1175-src-data-weapons-ts-src-data-units-ts-ar

Conversation

@squne121

@squne121 squne121 commented Jul 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • src/data/weapons.ts を readonly definitionId ベースの readonly catalog に更新した
  • player_weapon_basic の最小 weapon seed を追加し、cooldown / projectile 数値は現 runtime mirror に揃えた
  • src/data/units.ts を readonly definitionId ベースの readonly catalog に更新し、ally_basic archetype seed を追加した

受け入れ条件の達成状況

  • AC1 WeaponDefinition が readonly definitionId: string を持つ
  • AC2 player_weapon_basic を readonly catalog entry として追加し、as const satisfies readonly WeaponDefinition[] を使用した
  • AC3 UnitDefinition が readonly definitionId: string を持つ
  • AC4 ally_basic を readonly catalog entry として追加し、as const satisfies readonly UnitDefinition[] を使用した
  • AC5 ally_basic に faction: 'ally' / role: 'ally_basic' / radius: 12 / speedPxPerSec: 140 / initialBehaviorState: 'inactive' / defaultTargetingPolicy: 'nearest_hostile' を反映した
  • AC6 WeaponDefinition を ownerFaction / fireCooldownMs / projectileRadius / projectileSpeedPxPerSec / projectileLifetimeMs を含む最小 shape に限定した
  • AC7 pnpm typecheck
  • AC8 pnpm lint
  • AC9 pnpm test
  • AC10 pnpm build

検証コマンド結果

  • rg -n "readonly definitionId: string" src/data/weapons.ts を実行し、型定義の更新を確認した
  • rg -n "definitionId: 'player_weapon_basic'" src/data/weapons.ts を実行し、weapon seed の追加を確認した
  • rg -n "readonly definitionId: string" src/data/units.ts を実行し、型定義の更新を確認した
  • rg -n "definitionId: 'ally_basic'" src/data/units.ts を実行し、unit seed の追加を確認した
  • rg -F -n "faction: 'ally'" src/data/units.ts を実行し、ally faction を確認した
  • rg -F -n "role: 'ally_basic'" src/data/units.ts を実行し、ally role を確認した
  • rg -F -n "radius: 12" src/data/units.ts を実行し、半径の seed 値を確認した
  • rg -F -n "speedPxPerSec: 140" src/data/units.ts を実行し、速度の seed 値を確認した
  • rg -F -n "initialBehaviorState: 'inactive'" src/data/units.ts を実行し、初期 behavior を確認した
  • rg -F -n "defaultTargetingPolicy: 'nearest_hostile'" src/data/units.ts を実行し、初期 targeting を確認した
  • rg -F -n "ownerFaction: 'player'" src/data/weapons.ts を実行し、owner faction を確認した
  • rg -F -n "fireCooldownMs:" src/data/weapons.ts を実行し、cooldown field を確認した
  • rg -F -n "projectileRadius:" src/data/weapons.ts を実行し、projectile radius field を確認した
  • rg -F -n "projectileSpeedPxPerSec:" src/data/weapons.ts を実行し、projectile speed field を確認した
  • rg -F -n "projectileLifetimeMs:" src/data/weapons.ts を実行し、projectile lifetime field を確認した
  • pnpm typecheck を実行し、型検査が通ることを確認した
  • pnpm lint を実行し、lint が通ることを確認した
  • pnpm test を実行し、既存テスト一式が通ることを確認した
  • pnpm build を実行し、ビルドが通ることを確認した

Allowed Paths 遵守

  • 変更ファイルは src/data/weapons.ts と src/data/units.ts のみ
  • runtime consumer / docs / tests への変更は行っていない

Checks

  • pnpm typecheck を実行し、型検査が通ることを確認した
  • pnpm lint を実行し、lint が通ることを確認した
  • pnpm test を実行し、既存テスト一式が通ることを確認した
  • pnpm build を実行し、ビルドが通ることを確認した

Schema Change Applicability

  • decision: schema_change
  • reason: WeaponDefinition と UnitDefinition の exported shape を definitionId ベースへ変更し、readonly catalog seed を追加した

Schema Consumer Inventory

変更対象 schema: src/data/weapons.ts:WeaponDefinition, src/data/units.ts:UnitDefinition

before/after 差分:

# before
WeaponDefinition:
  id: string
UnitDefinition:
  id: string

# after
WeaponDefinition:
  definitionId: string
  ownerFaction: "'player' | 'ally' | 'enemy' | 'neutral'"
  fireCooldownMs: number
  projectileRadius: number
  projectileSpeedPxPerSec: number
  projectileLifetimeMs: number
UnitDefinition:
  definitionId: string
  faction: "'player' | 'ally' | 'enemy' | 'neutral'"
  role: "'ace_player' | 'ally_basic' | 'enemy_chaser' | 'objective' | 'neutral_obstacle'"
  radius: number
  speedPxPerSec: number
  initialBehaviorState: "'inactive' | 'acquire_target' | 'move_to_engage' | 'attack' | 'retreat' | 'destroyed'"
  defaultTargetingPolicy: "'focus_player' | 'assist_player_threat' | 'nearest_hostile' | 'ignore'"

Consumer 列挙(rg コマンド例と結果):

rg -l "WeaponDefinition|weaponDefinitions|UnitDefinition|unitDefinitions" src tests docs
src/data/units.ts
src/data/weapons.ts

Consumer 更新状況:

Consumer ファイル 更新有無 備考
src/data/weapons.ts 更新済み producer 定義本体
src/data/units.ts 更新済み producer 定義本体

互換性判断

この schema 変更は catalog producer 自身の整備であり、現時点では外部 consumer が存在しない前提で互換性を評価しています。

  • change_type: rename
  • compatibility: breaking
  • migration_required: no
  • migration_or_followup: N/A
  • reason: 現時点では外部 consumer が存在せず、catalog producer 自身の shape を seed 追加に合わせて更新している

Safety Claim Matrix

Claim Implemented? Not controlled Evidence Follow-up
本 PR は安全境界・権限・サンドボックス・workflow gate を変更しない yes changed paths が src/data/weapons.ts, src/data/units.ts のみ N/A

Notes

  • Related issue: Closes 実装: src/data/weapons.ts と src/data/units.ts を実体化して armament catalog を bootstrap する #1175。対象 Issue の最小 catalog bootstrap を完了する PR です。
  • MVP scope: 空 catalog の bootstrap のみを扱い、runtime consumer 接続や system 側の置換は含めません。
  • Runtime mirror: player_weapon_basic は weaponIntervalMs=280 / PROJECTILE_RADIUS_PX=4 / PROJECTILE_SPEED_PX_PER_SEC=520 / PROJECTILE_LIFETIME_MS=1200 に合わせ、future consumer が読んでも現挙動を変えない seed にしています。
  • AI / NotebookLM usage: gpt-5.3-codex-spark を bounded edit helper として使い、src/data/weapons.ts / src/data/units.ts の 2 ファイルだけを更新しました。

@squne121

squne121 commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author
TEST_VERDICT:
  result: PASS
  mergeable: UNKNOWN
  merge_state_status: UNKNOWN
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 19
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

## 検証結果レポート

### Issue #1175: src/data catalog bootstrap

| AC | 確認コマンド | 実行結果(要約) | exit code | 判定 |
|---|---|---|---|---|
| AC1 | `rg -n "readonly definitionId: string" src/data/weapons.ts` | `src/data/weapons.ts:2` | 0 | PASS |
| AC2 | `rg -n "definitionId: 'player_weapon_basic'" src/data/weapons.ts` | `src/data/weapons.ts:12` | 0 | PASS |
| AC3 | `rg -n "readonly definitionId: string" src/data/units.ts` | `src/data/units.ts:2` | 0 | PASS |
| AC4 | `rg -n "definitionId: 'ally_basic'" src/data/units.ts` | `src/data/units.ts:13` | 0 | PASS |
| AC5 | `rg -F -n ... src/data/units.ts` | required literals found | 0 | PASS |
| AC6 | `rg -F -n ... src/data/weapons.ts` | required literals found | 0 | PASS |
| AC7 | `pnpm typecheck` | `$ tsc --noEmit` | 0 | PASS |
| AC8 | `pnpm lint` | `$ eslint .` | 0 | PASS |
| AC9 | `pnpm test` | `86 files passed`, `1258 tests passed` | 0 | PASS |
| AC10 | `pnpm build` | `$ tsc && vite build`, `built in 137ms` | 0 | PASS |

### 総合判定

- 全 AC PASS: YES
- FAIL した AC: なし
- SKIP した AC: なし
- human_review_required: NO

@github-actions

github-actions Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Preview URL

Preview removed (PR #1263 closed).

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOOP_VERDICT_V2

verdict: REQUEST_CHANGES
reviewed_head_sha: "82a1ec125a32567a3d086b7dff5ca3adf3734b24"
merge_ready: false
mergeability:
  mergeable: "MERGEABLE"
  merge_state_status: "BEHIND"
blockers:
  - "TEST_VERDICT_MACHINE v1 が current head 82a1ec125a32567a3d086b7dff5ca3adf3734b24 に head-scoped で結び付いていません。comment YAML に head_sha がなく、https://github.com/squne121/loop-protocol/pull/1263#issuecomment-4854409270 の branch_behind_main: false が live merge_state_status=BEHIND と不整合なため、証拠を stale でないと判定できません。"
required_auto_actions:
  - kind: update_branch
    executor: implementation-worker
    skill: implement-issue.update_branch
    blocking_merge_ready: true
    mechanical: true
    expected_head_sha: "82a1ec125a32567a3d086b7dff5ca3adf3734b24"
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
  status: ok
allowed_paths_gate_source: review_subagent

@squne121

squne121 commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author
TEST_VERDICT:
  result: PASS
  head_sha: "be9f6ede803f6d6d34f70597485c08322388431d"
  reviewed_head_sha: "be9f6ede803f6d6d34f70597485c08322388431d"
  mergeable: MERGEABLE
  merge_state_status: BLOCKED
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 19
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

## 検証結果レポート

### Issue #1175: src/data catalog bootstrap

| AC | 確認コマンド | 実行結果(要約) | exit code | 判定 |
|---|---|---|---|---|
| AC1 | `rg -n "readonly definitionId: string" src/data/weapons.ts` | `src/data/weapons.ts:2` | 0 | PASS |
| AC2 | `rg -n "definitionId: 'player_weapon_basic'" src/data/weapons.ts` | `src/data/weapons.ts:12` | 0 | PASS |
| AC3 | `rg -n "readonly definitionId: string" src/data/units.ts` | `src/data/units.ts:2` | 0 | PASS |
| AC4 | `rg -n "definitionId: 'ally_basic'" src/data/units.ts` | `src/data/units.ts:13` | 0 | PASS |
| AC5 | `rg -F -n ... src/data/units.ts` | required literals found | 0 | PASS |
| AC6 | `rg -F -n ... src/data/weapons.ts` | required literals found | 0 | PASS |
| AC7 | `pnpm typecheck` | `$ tsc --noEmit` | 0 | PASS |
| AC8 | `pnpm lint` | `$ eslint .` | 0 | PASS |
| AC9 | `pnpm test` | `86 files passed`, `1258 tests passed` | 0 | PASS |
| AC10 | `pnpm build` | `$ tsc && vite build`, `built in 137ms` | 0 | PASS |

### 総合判定

- 全 AC PASS: YES
- FAIL した AC: なし
- SKIP した AC: なし
- human_review_required: NO
- reviewed_head_sha: `be9f6ede803f6d6d34f70597485c08322388431d`
- mergeability: `MERGEABLE / BLOCKED`

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, merge_state_status=CLEAN

Evidence Check

  • AC coverage: linked issue #1175 の AC1-AC10 は PR 本文の ## 受け入れ条件の達成状況 と current diff で充足を確認。
  • Allowed Paths: current head be9f6ede803f6d6d34f70597485c08322388431d の changed files は src/data/units.ts, src/data/weapons.ts のみで、ALLOWED_PATHS_GATE_RESULT_V1.status=ok。
  • CI Verification: ci_verdict_summary.py --expected-head-sha be9f6ede803f6d6d34f70597485c08322388431d は status=all_pass。
  • 検証コマンド結果: 最新 TEST_VERDICT_MACHINE は current head に head_sha/reviewed_head_sha=be9f6ede803f6d6d34f70597485c08322388431d で bind され、verification_commands_pass=19, verification_commands_fail=0, verification_skipped_count=0。

Blockers

  • なし

Non-blockers

  • 最新 TEST_VERDICT_MACHINE コメント内の merge_state_status=BLOCKED は、required checks 完了前の一時状態とみなし、current-head の live PR state (MERGEABLE/CLEAN) と ci_verdict_summary.py で再確認済み。

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: "be9f6ede803f6d6d34f70597485c08322388431d"
merge_ready: true
mergeability:
  mergeable: "MERGEABLE"
  merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
  status: ok
allowed_paths_gate_source: review_subagent

@squne121

squne121 commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author

敵対的レビュー結論: REQUEST_CHANGES

PR #1263 は src/data/weapons.ts / src/data/units.ts の2ファイルだけを変更し、空 catalog を definitionId ベースの readonly catalog seed にする小さなPRです。PR本文上も current head は be9f6ede803f6d6d34f70597485c08322388431d、変更ファイル数は2、追加34・削除4です。

ただし、このまま merge すべきではありません。 理由は、weaponDefinitions の数値 seed が「将来 consumer が参照可能な bootstrap catalog」というIssue目的に反して、現runtime値と食い違っているためです。現時点で consumer がないのでテストは通りますが、後続 consumer がこの catalog を読む瞬間に firing behavior が静かに変わります。


P0: player_weapon_basic の数値が runtime authority と衝突している

PR head の src/data/weapons.ts は player_weapon_basic を以下で定義しています。

fireCooldownMs: 350
projectileRadius: 8
projectileSpeedPxPerSec: 520
projectileLifetimeMs: 900

これはPR head実体で確認できます。

一方、現runtimeは以下です。

項目 | PR catalog | 現runtime / SSOT | 判定 -- | -- | -- | -- fire cooldown | 350 | player.weaponIntervalMs = 280 | 不一致 projectile radius | 8 | PROJECTILE_RADIUS_PX = 4 | 不一致 projectile speed | 520 | PROJECTILE_SPEED_PX_PER_SEC = 520 | 一致 projectile lifetime | 900 | PROJECTILE_LIFETIME_MS = 1200 | 不一致

createInitialGameState() の player default は weaponIntervalMs: 280 であり、runCombatSystem() は発射時に state.player.weaponIntervalMs を cooldown に使います。さらに projectile 生成は radius 4、speed 520、lifetime 1200、damage は state.progress.weaponPower snapshot です。

Issue #1175 は「後続 consumer が参照可能な最小 catalog seed」を作ることが目的で、runtime consumer 接続は out of scope です。だからこそ、catalog seed は future consumer が読んでも挙動を変えない値、つまり現runtime値の写像であるべきです。Issue側も damage を持ち込まず、progress.weaponPower の authority と衝突しない最小 schema に留める前提です。

movement-projectile.md でも fire_cooldown_ms の initial implementation default は既存 GameState weaponIntervalMs = 280 とされています。projectile speed / lifetime は当初 TBD 扱いでしたが、現runtimeではすでに CombatSystem 側に concrete value が存在します。

必須修正

player_weapon_basic は最低限こう直すべきです。

export const weaponDefinitions = [
  {
    definitionId: 'player_weapon_basic',
    ownerFaction: 'player',
    fireCooldownMs: 280,
    projectileRadius: 4,
    projectileSpeedPxPerSec: 520,
    projectileLifetimeMs: 1200,
  },
] as const satisfies readonly WeaponDefinition[]

このPRの性質は「balance tuning」ではなく「catalog bootstrap」です。したがって、350 / 8 / 900 のような新規 balance 値を混入させるのは危険です。src/data/CLAUDE.md も、src/data は純粋データ列挙のみ、型変更は import 元への影響が大きいので別Issue、としています。


P1: CI・preview・AC PASS は、このPRの本質的リスクを検出できていない

このPRは最新headで workflow が全て成功しており、deploy-pages / ci / hook integrity / manifest / Japanese content check が completed success です。

ただし、現時点で weaponDefinitions と unitDefinitions はそれぞれ定義ファイル以外から参照されていません。検索結果でも weaponDefinitions は src/data/weapons.ts のみ、unitDefinitions は src/data/units.ts のみです。

つまり、pnpm typecheck / lint / test / build が通っても、catalog値がruntime値と一致しているかは検証されません。 これは false green です。Issue #1175 のコメントでも、実装前レビュー段階から「consumer 不在」「grep AC の false green」「weapon damage / runtime authority conflict」が問題視されていました。

PR comment上は、一度 head binding 不備で REQUEST_CHANGES になった後、最新headでは APPROVE に転じています。これは証跡 freshness とCI整合の観点では改善されていますが、今回の数値衝突はその後も残っています。


P1: 配布物レビューとしては「live assets verified」だけでは動作保証にならない

PR preview workflow は self-repo PR のみを対象に、head SHA checkout、pnpm typecheck / lint / test、PR別 base path /loop-protocol/pr-<number>/、preview storage namespace pr-<number>、commit SHA injection を行っています。

さらに dist 内の asset base path、preview storage namespace、commit SHA を grep し、GitHub Pages 配下へ pr-<number> destination で deploy し、live index と asset path を curl で検証しています。

この実装は、Vite / GitHub Pages の基本に沿っています。Vite公式は GitHub Pages の repository page では base を /<REPO>/ にするよう説明しており、GitHub Pages は repository から HTML/CSS/JS 等を公開する静的ホスティングです。(vitejs)

ただし、このPRでは runtime consumer が存在しないため、previewで確認できるのは「bundleが配信され、asset path と namespace が壊れていない」ことまでです。weaponDefinitions が実際に発射挙動へ適用された場合に cooldown/radius/lifetime が維持されることは、現preview証跡では保証されません。


P2: UnitDefinition / ally_basic 側は妥当

unitDefinitions の ally_basic は、faction: 'ally'、role: 'ally_basic'、radius: 12、speedPxPerSec: 140、initialBehaviorState: 'inactive'、defaultTargetingPolicy: 'nearest_hostile' です。

これは現runtimeの createDefaultAllyState(1) と一致しています。runtime 側は role: 'ally_basic'、faction: 'ally'、behaviorState: 'inactive'、targetingPolicy: 'nearest_hostile'、radius: 12、speedPxPerSec: 140 を返します。

また、x / y を catalog に入れていない点も良いです。spawn位置と archetype definition を混ぜていません。


P2: as const satisfies readonly ...[] の採用は正しい

このPRは enemies.ts の既存 pattern に寄せています。enemies.ts は readonly definitionId を持つ interface と、as const satisfies readonly EnemyDefinition[] の readonly catalog を使っています。

TypeScript公式上も、satisfies は式の具体的な型情報を保持しながら target type への適合を検証するための機能です。as const は literal widening を抑制し、object property を readonly にし、array literal を readonly tuple にします。今回のような静的 catalog seed には適切です。(TypeScript) (TypeScript)


P2: storage / preview namespace の扱いは現時点では良いが、後続PRで過信してはいけない

upgrade.md は target: progress.weaponPower を正本とし、validate → debit → apply → snapshot、保存成功後のみ live state commit、次 sortie 反映、既存 projectile への retroactive 適用禁止を定めています。

また、PR preview storage key は loop-protocol.preview.pr-<number>.mvp.save、production は loop-protocol.mvp.save と分離されています。VITE_LOOP_STORAGE_NAMESPACE は build-time namespace であり、非秘密値のみを許可する扱いです。

これはWeb仕様上も必要です。localStorage は origin 単位で保持され、file: URL の挙動は保証されません。WHATWG Web Storage は複数window間の locking を前提にできないこと、setItem() が QuotaExceededError を投げ得ることも明記しています。(MDNウェブドキュメント)

Viteの VITE_* env は client bundle に露出され、build時に静的置換されるため、namespaceのような非秘密値に限定するのは正しいです。(vitejs)


推奨する merge 条件

このPRは以下を満たせば approve 可能です。

  1. src/data/weapons.ts の player_weapon_basic を runtime mirror 値に修正する。

    • fireCooldownMs: 280

    • projectileRadius: 4

    • projectileSpeedPxPerSec: 520

    • projectileLifetimeMs: 1200

  2. PR本文またはコメントに明記する。

    • この catalog は future consumer seed であり、現runtime consumer はまだ存在しない。

    • 後続 consumer Issue では CombatSystem hardcode と catalog 値の同値性をテストで固定してから移行する。

    • damage は追加しない。damage authority は progress.weaponPower のまま維持する。

  3. 可能なら follow-up Issue を切る。

    • weaponDefinitions を CombatSystem に接続する migration。

    • migration時に、既存発射挙動の golden test を追加する。

    • weaponIntervalMs / projectile constants の二重SSOTを解消する。


GitHubに貼るレビュー案

## Adversarial review: REQUEST_CHANGES

PR #1263 の目的(src/data/weapons.ts / src/data/units.ts の空 catalog を definitionId ベースの readonly seed にする)は妥当です。UnitDefinition / ally_basic は現 createDefaultAllyState(1) と一致しており、この部分は問題ありません。

ただし player_weapon_basic の数値 seed は merge 前に修正が必要です。

現 PR:

fireCooldownMs: 350
projectileRadius: 8
projectileSpeedPxPerSec: 520
projectileLifetimeMs: 900
</code></pre><p>現 runtime:</p><pre><code class="language-ts">state.player.weaponIntervalMs = 280
PROJECTILE_RADIUS_PX = 4
PROJECTILE_SPEED_PX_PER_SEC = 520
PROJECTILE_LIFETIME_MS = 1200
</code></pre><p>このPRは runtime consumer をまだ追加しないため、CI / preview / grep AC はこの不一致を検出できません。しかし #1175 の目的は「後続 consumer が参照可能な最小 catalog seed」です。後続 consumer がこの catalog を読むと、fire cooldown / projectile radius / lifetime が意図せず変わります。</p><p>必須修正案:</p><pre><code class="language-ts">export const weaponDefinitions = [
  {
    definitionId: 'player_weapon_basic',
    ownerFaction: 'player',
    fireCooldownMs: 280,
    projectileRadius: 4,
    projectileSpeedPxPerSec: 520,
    projectileLifetimeMs: 1200,
  },
] as const satisfies readonly WeaponDefinition[]
</code></pre><p><code inline="">damage</code> を追加していない点、<code inline="">as const satisfies readonly ...[]</code> を使っている点、<code inline="">ally_basic</code> が spawn position を持たない archetype seed に留まっている点は良いです。</p><p>修正後、<code inline="">pnpm typecheck</code> / <code inline="">pnpm lint</code> / <code inline="">pnpm test</code> / <code inline="">pnpm build</code> の再実行結果を current head に bind してください。</p><pre><code></code></pre></body></html><!--EndFragment-->
</body>
</html>## 敵対的レビュー結論: **REQUEST_CHANGES**

PR #1263 は `src/data/weapons.ts` / `src/data/units.ts` の2ファイルだけを変更し、空 catalog を `definitionId` ベースの readonly catalog seed にする小さなPRです。PR本文上も current head は `be9f6ede803f6d6d34f70597485c08322388431d`、変更ファイル数は2、追加34・削除4です。

ただし、**このまま merge すべきではありません。** 理由は、`weaponDefinitions` の数値 seed が「将来 consumer が参照可能な bootstrap catalog」というIssue目的に反して、現runtime値と食い違っているためです。現時点で consumer がないのでテストは通りますが、後続 consumer がこの catalog を読む瞬間に firing behavior が静かに変わります。

---

## P0: `player_weapon_basic` の数値が runtime authority と衝突している

PR head の `src/data/weapons.ts` は `player_weapon_basic` を以下で定義しています。

```ts
fireCooldownMs: 350
projectileRadius: 8
projectileSpeedPxPerSec: 520
projectileLifetimeMs: 900

これはPR head実体で確認できます。

一方、現runtimeは以下です。

項目 PR catalog 現runtime / SSOT 判定
fire cooldown 350 player.weaponIntervalMs = 280 不一致
projectile radius 8 PROJECTILE_RADIUS_PX = 4 不一致
projectile speed 520 PROJECTILE_SPEED_PX_PER_SEC = 520 一致
projectile lifetime 900 PROJECTILE_LIFETIME_MS = 1200 不一致

createInitialGameState() の player default は weaponIntervalMs: 280 であり、runCombatSystem() は発射時に state.player.weaponIntervalMs を cooldown に使います。さらに projectile 生成は radius 4、speed 520、lifetime 1200、damage は state.progress.weaponPower snapshot です。

Issue #1175 は「後続 consumer が参照可能な最小 catalog seed」を作ることが目的で、runtime consumer 接続は out of scope です。だからこそ、catalog seed は future consumer が読んでも挙動を変えない値、つまり現runtime値の写像であるべきです。Issue側も damage を持ち込まず、progress.weaponPower の authority と衝突しない最小 schema に留める前提です。

movement-projectile.md でも fire_cooldown_ms の initial implementation default は既存 GameState weaponIntervalMs = 280 とされています。projectile speed / lifetime は当初 TBD 扱いでしたが、現runtimeではすでに CombatSystem 側に concrete value が存在します。

必須修正

player_weapon_basic は最低限こう直すべきです。

export const weaponDefinitions = [
  {
    definitionId: 'player_weapon_basic',
    ownerFaction: 'player',
    fireCooldownMs: 280,
    projectileRadius: 4,
    projectileSpeedPxPerSec: 520,
    projectileLifetimeMs: 1200,
  },
] as const satisfies readonly WeaponDefinition[]

このPRの性質は「balance tuning」ではなく「catalog bootstrap」です。したがって、350 / 8 / 900 のような新規 balance 値を混入させるのは危険です。src/data/CLAUDE.md も、src/data は純粋データ列挙のみ、型変更は import 元への影響が大きいので別Issue、としています。


P1: CI・preview・AC PASS は、このPRの本質的リスクを検出できていない

このPRは最新headで workflow が全て成功しており、deploy-pages / ci / hook integrity / manifest / Japanese content check が completed success です。

ただし、現時点で weaponDefinitions と unitDefinitions はそれぞれ定義ファイル以外から参照されていません。検索結果でも weaponDefinitions は src/data/weapons.ts のみ、unitDefinitions は src/data/units.ts のみです。

つまり、pnpm typecheck / lint / test / build が通っても、catalog値がruntime値と一致しているかは検証されません。 これは false green です。Issue #1175 のコメントでも、実装前レビュー段階から「consumer 不在」「grep AC の false green」「weapon damage / runtime authority conflict」が問題視されていました。

PR comment上は、一度 head binding 不備で REQUEST_CHANGES になった後、最新headでは APPROVE に転じています。これは証跡 freshness とCI整合の観点では改善されていますが、今回の数値衝突はその後も残っています。


P1: 配布物レビューとしては「live assets verified」だけでは動作保証にならない

PR preview workflow は self-repo PR のみを対象に、head SHA checkout、pnpm typecheck / lint / test、PR別 base path /loop-protocol/pr-<number>/、preview storage namespace pr-<number>、commit SHA injection を行っています。

さらに dist 内の asset base path、preview storage namespace、commit SHA を grep し、GitHub Pages 配下へ pr-<number> destination で deploy し、live index と asset path を curl で検証しています。

この実装は、Vite / GitHub Pages の基本に沿っています。Vite公式は GitHub Pages の repository page では base を /<REPO>/ にするよう説明しており、GitHub Pages は repository から HTML/CSS/JS 等を公開する静的ホスティングです。([vitejs]1)

ただし、このPRでは runtime consumer が存在しないため、previewで確認できるのは「bundleが配信され、asset path と namespace が壊れていない」ことまでです。weaponDefinitions が実際に発射挙動へ適用された場合に cooldown/radius/lifetime が維持されることは、現preview証跡では保証されません。


P2: UnitDefinition / ally_basic 側は妥当

unitDefinitions の ally_basic は、faction: 'ally'、role: 'ally_basic'、radius: 12、speedPxPerSec: 140、initialBehaviorState: 'inactive'、defaultTargetingPolicy: 'nearest_hostile' です。

これは現runtimeの createDefaultAllyState(1) と一致しています。runtime 側は role: 'ally_basic'、faction: 'ally'、behaviorState: 'inactive'、targetingPolicy: 'nearest_hostile'、radius: 12、speedPxPerSec: 140 を返します。

また、x / y を catalog に入れていない点も良いです。spawn位置と archetype definition を混ぜていません。


P2: as const satisfies readonly ...[] の採用は正しい

このPRは enemies.ts の既存 pattern に寄せています。enemies.ts は readonly definitionId を持つ interface と、as const satisfies readonly EnemyDefinition[] の readonly catalog を使っています。

TypeScript公式上も、satisfies は式の具体的な型情報を保持しながら target type への適合を検証するための機能です。as const は literal widening を抑制し、object property を readonly にし、array literal を readonly tuple にします。今回のような静的 catalog seed には適切です。([TypeScript]2) ([TypeScript]3)


P2: storage / preview namespace の扱いは現時点では良いが、後続PRで過信してはいけない

upgrade.md は target: progress.weaponPower を正本とし、validate → debit → apply → snapshot、保存成功後のみ live state commit、次 sortie 反映、既存 projectile への retroactive 適用禁止を定めています。

また、PR preview storage key は loop-protocol.preview.pr-<number>.mvp.save、production は loop-protocol.mvp.save と分離されています。VITE_LOOP_STORAGE_NAMESPACE は build-time namespace であり、非秘密値のみを許可する扱いです。

これはWeb仕様上も必要です。localStorage は origin 単位で保持され、file: URL の挙動は保証されません。WHATWG Web Storage は複数window間の locking を前提にできないこと、setItem() が QuotaExceededError を投げ得ることも明記しています。([MDNウェブドキュメント]4)

Viteの VITE_* env は client bundle に露出され、build時に静的置換されるため、namespaceのような非秘密値に限定するのは正しいです。([vitejs]5)


推奨する merge 条件

このPRは以下を満たせば approve 可能です。

  1. src/data/weapons.ts の player_weapon_basic を runtime mirror 値に修正する。

    • fireCooldownMs: 280
    • projectileRadius: 4
    • projectileSpeedPxPerSec: 520
    • projectileLifetimeMs: 1200
  2. PR本文またはコメントに明記する。

    • この catalog は future consumer seed であり、現runtime consumer はまだ存在しない。
    • 後続 consumer Issue では CombatSystem hardcode と catalog 値の同値性をテストで固定してから移行する。
    • damage は追加しない。damage authority は progress.weaponPower のまま維持する。
  3. 可能なら follow-up Issue を切る。

    • weaponDefinitions を CombatSystem に接続する migration。
    • migration時に、既存発射挙動の golden test を追加する。
    • weaponIntervalMs / projectile constants の二重SSOTを解消する。

GitHubに貼るレビュー案

## Adversarial review: REQUEST_CHANGES

PR #1263 の目的(`src/data/weapons.ts` / `src/data/units.ts` の空 catalog を `definitionId` ベースの readonly seed にする)は妥当です。`UnitDefinition` / `ally_basic` は現 `createDefaultAllyState(1)` と一致しており、この部分は問題ありません。

ただし `player_weapon_basic` の数値 seed は merge 前に修正が必要です。

現 PR:

```ts
fireCooldownMs: 350
projectileRadius: 8
projectileSpeedPxPerSec: 520
projectileLifetimeMs: 900

現 runtime:

state.player.weaponIntervalMs = 280
PROJECTILE_RADIUS_PX = 4
PROJECTILE_SPEED_PX_PER_SEC = 520
PROJECTILE_LIFETIME_MS = 1200

このPRは runtime consumer をまだ追加しないため、CI / preview / grep AC はこの不一致を検出できません。しかし #1175 の目的は「後続 consumer が参照可能な最小 catalog seed」です。後続 consumer がこの catalog を読むと、fire cooldown / projectile radius / lifetime が意図せず変わります。

必須修正案:

export const weaponDefinitions = [
  {
    definitionId: 'player_weapon_basic',
    ownerFaction: 'player',
    fireCooldownMs: 280,
    projectileRadius: 4,
    projectileSpeedPxPerSec: 520,
    projectileLifetimeMs: 1200,
  },
] as const satisfies readonly WeaponDefinition[]

damage を追加していない点、as const satisfies readonly ...[] を使っている点、ally_basic が spawn position を持たない archetype seed に留まっている点は良いです。

修正後、pnpm typecheck / pnpm lint / pnpm test / pnpm build の再実行結果を current head に bind してください。

@squne121

squne121 commented Jul 1, 2026

Copy link
Copy Markdown
Owner Author
TEST_VERDICT:
  result: PASS
  head_sha: "5d5d1c1eeac512937e788cb287a458fb5bf28446"
  reviewed_head_sha: "5d5d1c1eeac512937e788cb287a458fb5bf28446"
  mergeable: MERGEABLE
  merge_state_status: BLOCKED
  branch_behind_main: false
  baseline_only: false
  verification_commands_pass: 19
  verification_commands_fail: 0
  verification_skipped_count: 0
  runtime_ac_results: []

## 検証結果レポート

### Issue #1175: src/data catalog bootstrap

| AC | 確認コマンド | 実行結果(要約) | exit code | 判定 |
|---|---|---|---|---|
| AC1 | `rg -n "readonly definitionId: string" src/data/weapons.ts` | `src/data/weapons.ts:2` | 0 | PASS |
| AC2 | `rg -n "definitionId: 'player_weapon_basic'" src/data/weapons.ts` | `src/data/weapons.ts:12` | 0 | PASS |
| AC3 | `rg -n "readonly definitionId: string" src/data/units.ts` | `src/data/units.ts:2` | 0 | PASS |
| AC4 | `rg -n "definitionId: 'ally_basic'" src/data/units.ts` | `src/data/units.ts:13` | 0 | PASS |
| AC5 | `rg -F -n ... src/data/units.ts` | required literals found | 0 | PASS |
| AC6 | `rg -F -n ... src/data/weapons.ts` | required literals found | 0 | PASS |
| AC7 | `pnpm typecheck` | `$ tsc --noEmit` | 0 | PASS |
| AC8 | `pnpm lint` | `$ eslint .` | 0 | PASS |
| AC9 | `pnpm test` | `87 files passed`, `1269 tests passed` | 0 | PASS |
| AC10 | `pnpm build` | `$ tsc && vite build`, `built in 488ms` | 0 | PASS |

### 総合判定

- 全 AC PASS: YES
- FAIL した AC: なし
- SKIP した AC: なし
- human_review_required: NO
- reviewed_head_sha: `5d5d1c1eeac512937e788cb287a458fb5bf28446`
- mergeability: `MERGEABLE / BLOCKED`

@squne121 squne121 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Mergeability

  • mergeable=MERGEABLE, merge_state_status=CLEAN

Evidence Check

  • 起点 comment: #1263 (comment) の REQUEST_CHANGES が求めた player_weapon_basic の runtime mirror 修正(fireCooldownMs: 280, projectileRadius: 4, projectileSpeedPxPerSec: 520, projectileLifetimeMs: 1200)は current diff で反映済み。
  • AC coverage: linked issue #1175 の AC1-AC10 は PR 本文の ## 受け入れ条件の達成状況 と current head 5d5d1c1eeac512937e788cb287a458fb5bf28446 の diff で充足を確認。
  • Allowed Paths: current head の changed files は src/data/units.ts, src/data/weapons.ts のみで、ALLOWED_PATHS_GATE_RESULT_V1.status=ok。
  • CI Verification: ci_verdict_summary.py --expected-head-sha 5d5d1c1eeac512937e788cb287a458fb5bf28446 は status=all_pass。
  • 検証コマンド結果: 最新 TEST_VERDICT_MACHINE は current head に head_sha/reviewed_head_sha=5d5d1c1eeac512937e788cb287a458fb5bf28446 で bind され、verification_commands_pass=19, verification_commands_fail=0, verification_skipped_count=0。

Blockers

  • なし

Non-blockers

  • 最新 TEST_VERDICT_MACHINE コメント内の merge_state_status=BLOCKED は required checks 完了前の一時状態で、required checks 完了後の live PR state (MERGEABLE/CLEAN) と current-head ci_verdict_summary.py で再確認済み。

LOOP_VERDICT_V2

verdict: APPROVE
reviewed_head_sha: "5d5d1c1eeac512937e788cb287a458fb5bf28446"
merge_ready: true
mergeability:
  mergeable: "MERGEABLE"
  merge_state_status: "CLEAN"
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
  status: ok
allowed_paths_gate_source: review_subagent

@squne121
squne121 merged commit 9815192 into main Jul 1, 2026
26 checks passed
@squne121
squne121 deleted the worktree-issue-1175-src-data-weapons-ts-src-data-units-ts-ar branch July 1, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

実装: src/data/weapons.ts と src/data/units.ts を実体化して armament catalog を bootstrap する

1 participant