Repository navigation
Closed
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Description
Machine-Readable Contract
contract_schema_version: v1
issue_kind: implementation
parent_issue: "975"
goal_ref: "unit taxonomy 型5種(Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy)を src/state に追加し、後続 stage の型基盤を確立する"
change_kind: code
ssot_sections: ["§5", "§6"]
stage: 2
blocked_by: []
dedupe_key: "follow-up:squne121/loop-protocol:pr/978:stage2"この stage の詳細契約は docs/product/features/unit-operations-and-npc-behavior.md §5, §6 が SSOT である。本文の AC/Allowed Paths/VC はそれと矛盾しない。
Parent Issue
関連 PR: #978(docs(#975): define unit operations and NPC behavior SSOT, merged)
Parent Goal Ref
- Goal: artifact §5 の
Faction/UnitRole/CommandIntent/NpcBehaviorState/TargetingPolicyを型レベルでsrc/stateに追加し、後続 stage(stage3〜stage8)の型基盤を確立する - Desired Destination: 5 enum union が
src/stateから export され、pnpm typecheck/pnpm testが緑で、ally collection / command buffer は追加されていない状態
Current Validated Scope
src/state/GameState.tsにFaction/UnitRole/CommandIntent/NpcBehaviorState/TargetingPolicyの型定義を追加するsrc/state/index.tsは既存のexport * from './GameState'で再 export が成立するため、通常変更不要。明示 export 方針に変更する場合のみ最小差分で編集する。tests/state/unit-taxonomy-types.test.tsに型存在確認テストを追加してよい(任意)
Remaining Parent Gaps
- stage3: command intent buffer と Z-equivalent mapping(本 Issue 完了後)
- stage4: deterministic target scoring pure function(本 Issue 完了後)
- stage5: ally_basic NPC state と semi-autonomous behavior(本 Issue 完了後)
- stage6: existing enemy_chaser を new taxonomy へ非破壊移行(本 Issue 完了後)
- stage7: assist_player DOM command affordance と Canvas visual cue(stage3/5 完了後)
- stage8: assist_player playtest self-explanation test と evidence policy(stage7 完了後)
Outcome
artifact §5 の Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy を型レベルで src/state に追加する。ally collection / command buffer / behavior runtime はまだ追加しない(型の export のみ)。
In Scope
src/state/GameState.tsへの 5 enum union 型定義追加src/state/index.tsからの export 追加(既存export * from './GameState'で成立する場合は変更不要)tests/state/unit-taxonomy-types.test.tsへの型存在確認テスト追加(任意)。追加する場合は literal union の値集合が §5 と一致することを型レベル(tsc --noEmit / TypeScript 型代入テスト)で確認する。enumやconstobject は作らない(runtime value を必要としないため)。
Out of Scope
- ally collection の実装(stage5 の責務)
- command buffer の実装(stage3 の責務)
- behavior runtime の実装(stage5/stage6 の責務)
- targeting scoring の実装(stage4 の責務)
- DOM affordance / Canvas cue の実装(stage7 の責務)
Acceptance Criteria
- AC1: 5 enum union(
Faction,UnitRole,CommandIntent,NpcBehaviorState,TargetingPolicy)が artifact §5 と逐語一致でsrc/stateから export される - AC2:
pnpm typecheckが緑 - AC3: 既存テストが緑(runtime 挙動不変)
- AC4: ally collection および command buffer が追加されていない(forbidden runtime fields が
src/stateに存在しない)
Stop Conditions
- Allowed Paths 外の変更が必要と判明した場合
- In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
- 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
- 後続 Phase / 別スコープへの波及が判明した場合
- nested SubAgent delegation が必要になった場合
- 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合
Required Skills
- TypeScript / TSC strict
- ECS(state / systems 分離)
Verification Commands
実装前は 5 型が未追加のため AC1 の rg は 0 件(baseline-expect: fail)。AC2/AC3 は型追加後に回帰しないことを確認する。AC4 は forbidden runtime fields が存在しないことを確認する(実装前後とも pass)。
# AC1
# baseline-expect: fail
$ rg -n "export type (Faction|UnitRole|CommandIntent|NpcBehaviorState|TargetingPolicy) =" src/state/GameState.ts# AC2
$ pnpm typecheck# AC3
$ pnpm test# AC4
# trivially_pass: absence check - src/state に allies/commandBuffer が存在しないことは実装前後とも成立する
# preflight-scope: pr_review_only
$ rg -n "allies|commandBuffer" src/state# Quality gate
$ pnpm lint
$ pnpm build
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.pyAllowed Paths
src/state/GameState.tssrc/state/index.ts(既存export * from './GameState'で再 export が成立する場合、変更不要)tests/state/unit-taxonomy-types.test.ts(型存在確認テストを追加する場合のみ)
Runtime Verification Applicability
- decision: not_applicable
- reason: 型 alias の追加のみで runtime 挙動・プロセス起動・通信・I/O を伴わない。検証は
pnpm typecheck/pnpm lint/pnpm test/pnpm buildと禁止語チェックで完結する。
Source
- dedupe_key:
follow-up:squne121/loop-protocol:pr/978:stage2 - artifact SSOT:
docs/product/features/unit-operations-and-npc-behavior.md§5, §6 - merged PR: docs(#975): define unit operations and NPC behavior SSOT #978
- research issue: 調査: 味方機体・敵機体の運用モデルと NPC 行動契約を正本化する #975
Metadata
Metadata
Assignees
Labels
agent/implementerAI implementer agentenhancementNew feature or requestphase/implementationImplementation phasetriage-requiredNeeds owner triage for priority decision
Activity
squne121 commentedon Jun 18, 2026
判定
REQUEST_CHANGES / Issue contract 修正後に着手可。
#981 の実装意図自体は妥当です。
docs/product/features/unit-operations-and-npc-behavior.md§5 の 5 型をsrc/stateに追加し、ally runtime / command buffer / behavior runtime をまだ入れない分割は、8-stage 分解の stage2 として正しいです。§5 の型定義も、Faction/UnitRole/CommandIntent/NpcBehaviorState/TargetingPolicyの literal union として固定されています。ただし、このまま Claude Code / Codex に渡すと、検証が壊れます。 実装より Issue 本文の品質が問題です。
Blocker 1: AC4 の
rg検証が逆向き#981 は AC4 で「ally collection / command buffer が追加されていない」ことを確認するために、次を VC にしています。
これは 0件であることを確認するコマンドとして不適切です。grep 系コマンドは「一致あり」を成功、「一致なし」を非 0 として扱う慣習があり、GNU grep の manual でも exit status は「selected line あり = 0、なし = 1、error = 2」と説明されています。
set -e系の test-runner では、禁止語が存在しない正常状態で失敗扱いになり得ます。([GNU]1)修正案:
! rg ...だけだとrgの実行エラーも成功扱いに反転し得るため、exit code 1 だけを「0件」として許容する形にしてください。Blocker 2: Runtime Verification Applicability が
deferredになっているのは不正確#981 は型追加のみで、runtime 挙動、プロセス起動、通信、I/O を要求していません。プロジェクトの runtime verification policy では、静的検証だけで完結するものは
not_applicable、プロセス起動・通信・I/O が必要なものがimmediate、後続統合まで成立しないものがdeferredです。さらに #981 の
deferred_destinationが#976になっていますが、#976 は hook 境界ドキュメント系の PR/Issue 文脈であり、unit taxonomy stage2 の検証先として不整合です。#981 の検証条件は「型が存在し、typecheck/test が通ること」なので、本 Issue 内で静的に閉じられます。修正案:
Blocker 3: 必須品質ゲートが足りない
#981 の Verification Commands は
pnpm typecheckとpnpm testだけですが、プロジェクト憲法は原則としてpnpm typecheck/pnpm lint/pnpm test/pnpm build/ Gemini routing pytest を必須検証として定義しています。実装テンプレート側も標準 VC として
pnpm typecheck/pnpm lint/pnpm test/pnpm buildを初期値にしています。修正案:
Blocker 4:
src/state/index.tsの編集要否が曖昧#981 は
src/state/index.tsから 5 型を export するとしていますが、現状src/state/index.tsはすでにexport * from './GameState'を持っています。つまりGameState.ts側でexport typeすれば、index からの再 export は既に成立します。ここを曖昧にすると、実装者が不要な差分を作る可能性があります。
修正案:
Blocker 5: 「型存在確認テスト」が runtime test として誤解されやすい
TypeScript の
typealias /export typeは型検査用で、JavaScript 出力には残りません。TypeScript 3.8 の公式ドキュメントもimport type/export typeは型文脈専用で、完全に erase されると説明しています。(TypeScript)したがって、Vitest の runtime assertion で「型が存在する」ことを検証しようとすると、空テスト・無意味テスト・runtime object 化の誘惑が出ます。ここは literal union 型 +
tsc --noEmitに寄せるべきです。TypeScript 公式 docs でも union type は複数型のいずれかを表す型、literal union は既知の値集合だけを受け付ける表現として説明されています。([TypeScript]3) (TypeScript)推奨実装:
禁止:
enumやconstobject を作ること。現 stage は runtime value を必要としていないため、JS 出力を増やす理由がありません。Major: Issue title が 3型しか書いていない
タイトルは
Faction / UnitRole / CommandIntentだけですが、AC1 と SSOT はNpcBehaviorState/TargetingPolicyも含む 5 型です。修正案:
または:
Major:
tests/が広すぎるAllowed Paths に
tests/全体を許可していますが、後続 stage3 #982、stage4 #983 もtests/を触ります。#982 は #981 に block され、#983 は #981/#982 に block されているので順序上は問題ありませんが、Scope Collision Preflight の観点では broad path は衝突を増やします。workflow は overlap がある場合に C1/C2/C3 判定と記録を要求しています。修正案:
配布物・Evidence の扱い
#981 は type-only stage なので、Pages preview、screenshot、artifact digest、retention-days などの配布証跡は不要です。PR #978 の spec は UI/playtest follow-up PR では commit SHA / Actions run ID / page_url or stable artifact / artifact names / retention-days / viewport / DPR / browser zoom 等を要求していますが、docs-only / type-only PR 自体には UI evidence を適用しない境界も明記しています。
この Issue で配布物品質を上げるなら、Pages 証跡を足すのではなく、型追加が runtime に漏れていないこと、禁止 field が入っていないこと、標準品質ゲートが通ることに限定してください。
修正版の実行プロンプト
PR 作成時:
Closes #981を入れる。Allowed Paths 遵守に、src/state/index.tsを変更したかどうかと理由を書く。Runtime Verification Applicabilityはnot_applicableとして扱う。理由は type-only / static verification only。停止条件:
Faction等を runtime value として必要にする設計が必要になった場合[-]実装: unit taxonomy 型 Faction / UnitRole / CommandIntent を src/state に追加する[/-][+]実装: unit taxonomy 型5種(Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy)を src/state に追加する[/+]squne121 commentedon Jun 18, 2026
Refinement Loop: Approved
The issue has been approved and is ready for implementation.
approvedsqune121 commentedon Jun 18, 2026
Contract Review Result
feat(#981): add unit taxonomy type aliases to src/state (#988)
squne121 commentedon Jun 18, 2026
post-merge-cleanup: 完了 (2026-06-18)