Skip to content

feat(#981): unit taxonomy 型5種を src/state に追加する(Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy) - #988

Merged
squne121 merged 1 commit into
mainfrom
issue-981-unit-taxonomy-types
Jun 18, 2026
Merged

squne121 merged 1 commit into
mainfrom
issue-981-unit-taxonomy-types

Conversation

@squne121

@squne121 squne121 commented Jun 18, 2026 •

Copy link
Copy Markdown
Owner

概要

Issue #981(stage 2)の実装。docs/product/features/unit-operations-and-npc-behavior.md §5 に定義された5型を src/state/GameState.ts に export type の literal union として追加する。

Closes #981(本 PR は Issue #981 を解決します)

変更内容

src/state/GameState.ts に以下5型を追加した。値集合は SSOT §5 と逐語一致。enum / runtime const object は一切追加していない。

  • Faction(所属陣営): 'player' | 'ally' | 'enemy' | 'neutral'
  • UnitRole(行動役割): 'ace_player' | 'ally_basic' | 'enemy_chaser' | 'objective' | 'neutral_obstacle'
  • CommandIntent(コマンド意図): 'none' | 'assist_player'
  • NpcBehaviorState(NPC行動状態): 'inactive' | 'acquire_target' | 'move_to_engage' | 'attack' | 'retreat' | 'destroyed'
  • TargetingPolicy(照準方針): 'focus_player' | 'assist_player_threat' | 'nearest_hostile' | 'ignore'

src/state/index.ts は変更なし。既存の export * from './GameState' により5型の再 export が成立するため変更不要。

Allowed Paths 遵守

変更ファイルは src/state/GameState.ts のみ。src/state/index.ts は変更なし(再 export 成立のため不要)。ally collection および command buffer は追加していない。

検証結果

AC 判定 備考
AC1: 5型が GameState.ts から export される 合格 rg "export type Faction|..." → 5件ヒット
AC2: pnpm typecheck 緑 合格 型エラーなし
AC3: 既存テスト緑 合格 51 ファイル・725 テスト全合格
AC4: ally collection / command buffer なし 合格(pr_review_only) diff 確認済み・追加なし

品質ゲート結果:

ゲート 判定
pnpm lint 合格
pnpm build 合格
uv run pytest モデルルーティングテスト 合格(21/21)

Runtime Verification Applicability(実行時検証適用判定)

型 alias の追加のみであり、runtime 挙動・プロセス起動・通信・I/O を伴わない。適用判定: not_applicable。静的型チェック(pnpm typecheck)と pnpm test のみで検証完了。

Safety Claim Matrix(安全性主張マトリクス)

本 PR は型定義の追加のみであり、runtime・認証・通信・権限・デプロイ・シークレット・Pages artifact を一切変更しない。該当項目なし。

§5 の 5 型(Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy)を
src/state/GameState.ts に export type の literal union として追加する。
runtime value / enum object は追加しない。ally collection / command buffer は追加しない。

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Preview URL

⏳ publish requested(asset-level live check 未検証 / Pages source 設定後に有効化): https://squne121.github.io/loop-protocol/pr-988/

Pages source の設定が必要な場合: Settings → Pages → Source → gh-pages (root)
base path 修正だけでは hosted runtime 復旧を保証しません。publish trigger / source fault は別問題として切り分けてください。
The preview will be removed when this PR is 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.

レビュー判定: REQUEST_CHANGES(self-authored のため --comment で投稿)

LOOP_VERDICT_V2:
  verdict: REQUEST_CHANGES
  merge_ready: false
  required_auto_actions: []
  allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
    detail: >
      contract_snapshot: https://github.com/squne121/loop-protocol/issues/981#issuecomment-4742232638
      expected_contract_fingerprint: sha256:5e2c82e291614d65ba9b1f900c9d722d6988c3a26ed3b4adb75ebb39151106a1
      contract_source_kind: issue_comment
      contract_source_id: IC_kwDOSfQcDc8AAAABGqi6Pg
      allowed_paths_in_contract:
        - src/state/GameState.ts
        - src/state/index.ts
        - tests/state/unit-taxonomy-types.test.ts
      actual_changed_files:
        - src/state/GameState.ts
      gate_result: ok (1ファイル、全て Allowed Paths 内)
  blockers:
    - id: B1
      kind: ci_failure
      detail: >
        PR Body Japanese Check が失敗している。
        prose_blocks=14 のうち failed_blocks=4。
        block[1] ratio=0.000 (jp=0, total=10)
        block[2] ratio=0.000 (jp=0, total=25)
        block[3] ratio=0.000 (jp=0, total=19)
        block[4] ratio=0.096 (jp=7, total=73)
        threshold=0.1 未満。
        検証結果テーブルの行と Safety Claim Matrix 行が英語主体で比率を下げている。
        各 prose block に日本語テキストを補充するか、日本語比率を threshold 以上にする修正が必要。
  fix_delta: >
    PR body の日本語比率不足 prose block を修正する。
    具体的には以下のセクション内の英語のみのブロックに日本語説明を追加する:
    - 検証結果テーブル(PASS 等の英語のみセル行)
    - Safety Claim Matrix セクション(現状 ratio=0.096)
    各 prose block の日本語比率を 0.1 以上にすること。
  notes: >
    実装内容自体は正確。
    diff は src/state/GameState.ts のみ(Allowed Paths 内)。
    5型の値集合は SSOT §5 と逐語一致を確認(Faction/UnitRole/CommandIntent/NpcBehaviorState/TargetingPolicy)。
    enum・runtime const object なし(export type literal union のみ)。
    AC1/AC2/AC3/AC4 は全て充足。
    pnpm lint/build/typecheck/test/e2e: CI pass。
    python-test: pending。
    唯一のブロッカーは PR body の日本語 CI ゲート失敗(B1)。
    PR body の日本語比率を修正すれば即 APPROVE 可能。

詳細

Allowed Paths Gate(review_subagent 独立再計算)

contract_snapshot(IC_kwDOSfQcDc8AAAABGqi6Pg、body_sha256=sha256:5e2c82e291614d65ba9b1f900c9d722d6988c3a26ed3b4adb75ebb39151106a1)の Allowed Paths:

  • src/state/GameState.ts
  • src/state/index.ts(変更なし可)
  • tests/state/unit-taxonomy-types.test.ts(任意)

実際の変更ファイル(gh pr diff --name-only で確認):

  • src/state/GameState.ts のみ

Allowed Paths 外の変更: なし。Gate: ok。

AC 確認結果

AC 判定 根拠
AC1: 5型が SSOT §5 と逐語一致 PASS diff で全5型の値集合を SSOT §5 と照合済み
AC2: pnpm typecheck 緑 PASS CI typecheck job: pass
AC3: 既存テスト緑 PASS CI test job: pass(725 tests)
AC4: ally collection / command buffer なし PASS diff に allies/commandBuffer フィールドなし確認

CI 状態

  • PR Body Japanese Check: fail(failed_blocks=4)← B1 ブロッカー
  • actionlint: pass
  • build: pass
  • deploy-pr: pass
  • e2e: pass
  • lint: pass
  • test: pass
  • typecheck: pass
  • validate-generated-artifact: pass
  • python-test: pending

ブロッカー詳細(B1)

PR Body Japanese Check が以下のエラーで失敗:

aggregate_ratio: 0.319
threshold: 0.1
prose_blocks: 14
failed_blocks: 4

--- 日本語比率不足の prose block ---
  [1] ratio=0.000 (jp=0, total=10)
  [2] ratio=0.000 (jp=0, total=19)
  [3] ratio=0.000 (jp=0, total=25)
  [4] ratio=0.096 (jp=7, total=73)
FAIL: 日本語比率不足 (aggregate=0.319, threshold=0.1, failed_blocks=4)

per-block 判定のため aggregate_ratio が閾値を超えていても各 block が 0.1 未満なら fail となる。検証結果テーブルおよび Safety Claim Matrix の行が英語のみのため比率不足。各 block の日本語比率を 0.1 以上に修正する必要がある。

実装品質所見

実装内容は問題なし。export type literal union のみ、runtime object なし、Allowed Paths 遵守、SSOT §5 との逐語一致を確認。PR body の CI ゲート修正のみで merge_ready になる。

@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.

PR レビュー結果

LOOP_VERDICT: APPROVE

(自己 PR のため --approve フラグ不使用。--comment で同等の判定を記録する。)

全 AC・Allowed Paths Gate・CI が pass。以下に独立検証結果を示す。


Allowed Paths Gate(review_subagent 独立再計算)

  • 変更ファイル(diff --name-only base...head): src/state/GameState.ts のみ
  • Contract Allowed Paths:
    • src/state/GameState.ts — 変更あり(許可範囲内)
    • src/state/index.ts — 変更なし(許可範囲内、既存 export * で再 export 成立)
    • tests/state/unit-taxonomy-types.test.ts — 変更なし(任意追加、未追加も問題なし)
  • Gate 結果: ok
  • Contract fingerprint: body_sha256: sha256:5e2c82e291614d65ba9b1f900c9d722d6988c3a26ed3b4adb75ebb39151106a1
  • Contract source: issue_comment / IC_kwDOSfQcDc8AAAABGqi6Pg(#981#issuecomment-4742232638)

AC 独立検証

AC 結果 根拠
AC1: 5型が SSOT §5 と逐語一致で export PASS diff で全5型を目視照合(下記参照)
AC2: pnpm typecheck 緑 PASS CI typecheck pass
AC3: 既存テスト緑 PASS CI test pass(725 tests)
AC4: allies / commandBuffer なし PASS diff に該当フィールドなし(pr_review_only 確認済み)

SSOT §5 逐語照合:

  • Faction: 'player' | 'ally' | 'enemy' | 'neutral' — 一致
  • UnitRole: 'ace_player' | 'ally_basic' | 'enemy_chaser' | 'objective' | 'neutral_obstacle' — 一致
  • CommandIntent: 'none' | 'assist_player' — 一致
  • NpcBehaviorState: 'inactive' | 'acquire_target' | 'move_to_engage' | 'attack' | 'retreat' | 'destroyed' — 一致
  • TargetingPolicy: 'focus_player' | 'assist_player_threat' | 'nearest_hostile' | 'ignore' — 一致

enum / runtime const object は追加されていない。export type のみ。


CI 全体状態

全 required ジョブ pass:

  • typecheck, lint, build, test, e2e, python-test, actionlint: pass
  • PR Body Japanese Check: pass(最新 run 27762337845)
  • ci-verdict-summary: pass

LOOP_VERDICT_V2:
  verdict: APPROVE
  merge_ready: true
  required_auto_actions: []
  reviewed_head_sha: "9e31e29256ebf5e5b8cbe6c895d7362cfcffb2e1"
  allowed_paths_gate:
    status: ok
    producer_role: review_subagent
    worker_report_used_as_canonical: false
    expected_contract_fingerprint: "sha256:5e2c82e291614d65ba9b1f900c9d722d6988c3a26ed3b4adb75ebb39151106a1"
    contract_source_kind: issue_comment
    contract_source_id: "IC_kwDOSfQcDc8AAAABGqi6Pg"
    changed_files:
      - "src/state/GameState.ts"
    allowed_paths:
      - "src/state/GameState.ts"
      - "src/state/index.ts"
      - "tests/state/unit-taxonomy-types.test.ts"
    violations: []
  blockers: []
  fix_delta: null
  notes: >
    5型全て SSOT §5 と逐語一致。runtime value(enum/const object)なし。
    Allowed Paths 外変更なし。CI 全 pass。PR body に Closes #981 含む。
    mergeStateStatus: CLEAN(branch protection required review 待ちのみ)。
    自己 PR のため --approve 不可、--comment で判定記録。

@squne121

Copy link
Copy Markdown
Owner Author

判定

コード差分は APPROVE 相当。merge 前の実質ブロッカーはコードではなく、PR がまだ draft である点です。 PR #988 は open / mergeable ですが draft: true なので、そのままでは GitHub 上 merge できません。GitHub 公式 docs でも draft PR は merge 不能と明記されています。 ([GitHub Docs]1)

実装自体は、#981 の stage2 契約どおり src/state/GameState.ts に 5 つの export type literal union を追加するだけで、変更ファイルも 1 ファイル・追加 36 行のみです。

確認結果

PR 差分は Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy を export type として追加しており、値集合は SSOT §5 の定義と一致しています。

src/state/index.ts は既に export * from './GameState' を持つため、PR 本文の「index.ts 変更不要」という判断も正しいです。

TypeScript の export type は出力 JS から消える type-only export なので、この PR の「runtime value を増やさない」という主張は妥当です。逆に enum は TypeScript 公式 docs 上も JavaScript の type-level 拡張ではない機能で、numeric enum は runtime object へ compile されます。今回 enum / const object を避けた判断は正しいです。([TypeScript]2) ([TypeScript]3)

CI / コメント状態

初回レビューコメントでは PR Body Japanese Check の失敗が唯一の blocker とされていました。 ただし同一 head SHA に対する workflow runs では、後続の Check Japanese Content が success になっており、ci / deploy-pages / agent-session-manifest も success です。

CI job 単位でも typecheck / test / build / actionlint / lint / e2e / python-test が success です。 PR Body Japanese Check も最新 run では success です。

敵対的レビューで残すべき指摘

1. draft のままなので merge_ready ではない

実装は問題ありませんが、PR は draft です。merge する意思があるなら、CI 緑確認後に ready for review へ移行する必要があります。これはコード品質ではなく GitHub workflow 上のブロッカーです。 ([GitHub Docs]1)

2. #981 の AC4 検証コマンドはまだ危険

#981 本文には AC4 として rg -n "allies|commandBuffer" src/state が残っています。これは「禁止語が存在しないこと」の確認としては機械 gate に向きません。取得結果上でも #981 はその bare rg を AC4 VC として保持しています。

過去コメントでも、禁止語検査は exit code 1 だけを「一致なし」として許容する形に修正すべき、と指摘されています。 PR #988 自体の差分には allies / commandBuffer は入っていないためコードブロッカーではありませんが、#981 を閉じるなら契約本文側の VC は修正した方がよいです。

推奨形:

bash -lc 'set +e; rg -n "allies|commandBuffer" src/state; status=$?; test "$status" -eq 1'

3. type-only なので preview URL を evidence 扱いしない

PR comment には preview URL が出ていますが、コメント自体が「asset-level live check 未検証」と述べています。 この PR は type-only なので Pages preview は acceptance evidence ではありません。判断材料は typecheck / test / build / lint と差分確認で十分です。

4. 型値集合の drift 検出は人間レビュー依存

Issue #981 では tests/state/unit-taxonomy-types.test.ts は任意です。 したがって現 PR がテストを足していないことは契約違反ではありません。ただし将来、値集合が SSOT からずれた場合、未使用の型 alias だけでは pnpm typecheck が drift を検出しにくいです。

追加するなら runtime test ではなく、compile-only の型代入テストに限定してください。TypeScript の union / literal type は、既知の値集合を型レベルで固定する用途に適しています。(TypeScript) ただし今回の stage では必須ではありません。

関連 Issue / PR との整合

#975 は「RTS/Z 指示 mode 前の unit taxonomy / NPC behavior の product SSOT 化」が目的で、8-stage follow-up の stage2 が「Faction / UnitRole / CommandIntent 型追加」です。

#978 はその SSOT を docs-only / research-only として merge 済みで、runtime 実装は後続 issue に deferred する方針でした。

#981 は stage2 として、5 型を src/state から export し、ally collection / command buffer は追加しないことを desired destination にしています。 PR #988 はこの範囲に収まっています。

後続の #982 は stage3 command intent buffer で #981 に block され、#983 は stage4 deterministic scoring で #981/#982 に block されています。 #984 / #985 / #986 も taxonomy 型を前提にしているため、この PR の merge は後続 stage の前提条件として妥当です。

次に出す指示

PR #988 の最終仕上げをしてください。

確認事項:
- head SHA `9e31e29256ebf5e5b8cbe6c895d7362cfcffb2e1` の最新 CI が全て success であることを確認する。
- `Check Japanese Content` の過去 failure は後続 success で解消済みとして扱う。
- 差分が `src/state/GameState.ts` の type-only export 追加のみであることを再確認する。
- `enum` / runtime const object / ally collection / command buffer / behavior runtime が追加されていないことを確認する。
- type-only PR のため Pages preview は acceptance evidence として扱わない。

修正が必要なら:
- #981 の AC4 VC を bare `rg -n "allies|commandBuffer" src/state` から、exit code 1 だけを「一致なし」として許容する fail-closed 形式へ修正する。
- PR が merge 対象なら draft を解除する。

完了条件:
- PR #988 を ready for review にする。
- PR コメントに「CI 緑、B1 解消、type-only のため runtime/Pages evidence N/A、#981 closes ready」と明記する。
- 人間承認が必要な merge 操作以外は停止しない。

結論として、PR #988 はコードとしては通してよいです。merge 前に残すべき実務上の処理は、draft 解除と、#981 の AC4 検証コマンド負債を直すか少なくとも follow-up 化することです。

@squne121
squne121 marked this pull request as ready for review June 18, 2026 13:33
@squne121

Copy link
Copy Markdown
Owner Author

impl-review-loop 完了報告

CI 緑・B1(PR body 日本語比率)解消済み・type-only のため runtime/Pages evidence N/A・#981 closes ready。

  • PR draft → ready for review に変換済み
  • 全 CI チェック pass(typecheck / test / lint / build / e2e / python-test / PR Body Japanese Check)
  • 変更ファイル: src/state/GameState.ts のみ(type-only export type、runtime value なし)
  • ally collection / command buffer / enum / const object は追加していない
  • SSOT §5 との逐語一致を確認済み

マージ判断を人間にお返しします。

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.

実装: unit taxonomy 型5種(Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy)を src/state に追加する

1 participant