Repository navigation
feat: SortieResult に endReason discriminated union を追加する (#680) - #709
Conversation
SortieResult を discriminated union に変更し、outcome と endReason の整合を型レベルで保証する。 victory は endReason: 'all_enemies_defeated'、defeat は 'player_hp_zero' | 'timeout' のみを許可する。 SortieEndReason 型(3 値)を追加し、M2 で到達不能な survival_timer を含まない。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Preview URLPreview removed (PR #709 closed). |
squne121
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES
Mergeability
- mergeable=MERGEABLE, merge_state_status=UNSTABLE
Evidence Check
- AC coverage: AC1〜AC11 すべて PASS(test-runner 証跡 + worktree 独立実行)
- AC9:
grep -n "enemies\.length\|length > 0" src/systems/SortieSystem.tsを worktree で実行済み。L41 コメント・L69 実装ともにstate.enemies.length > 0guard が存在し、vacuous truth 防止が維持されている。
- AC9:
- Allowed Paths 遵守: 変更ファイルは
docs/product/features/sortie.md/src/state/GameState.ts/src/systems/SortieSystem.ts/tests/sortie-system.test.tsの 4 ファイルのみ。linked issue の Allowed Paths と完全一致。 - Schema Change Applicability:
not_schema_changeが明示されており、diff 確認で外部 API / JSON schema / persistence schema への変更なし。Schema Consumer Inventory の提出は不要(正当)。 - Safety Claim Matrix:
N/Aが明示されており、safety-sensitive path(*transport*,*permission*,*sandbox*,*auth*,*mcp*,*tool*,.claude/skills/**等)への変更なし。Safety Claim Gate は適用外。 - 検証コマンド結果: PR 本文に
pnpm typecheck/lint/test/buildPASS の自己申告あり。TEST_VERDICT_MACHINE コメントは存在しないが、CI check run(head_sha=ad38e8990312da408fb3d8e37f75632e76800a83)で typecheck/lint/test/build すべて success(conclusion=success・対象 VC 対応)を確認済み。
CI Verification
| Check | 結果 | 備考 |
|---|---|---|
| typecheck | pass | |
| lint | pass | |
| test | pass | |
| build | pass | |
| python-test | pass | |
| actionlint | pass | |
| deploy-pr | pass | |
| validate-generated-artifact | pass | |
| PR Body Japanese Check | fail | PR 本文の日本語比率不足(aggregate_ratio=0.265, failed_blocks=8) |
| e2e | fail | toHaveScreenshot baseline 不一致。main ブランチでも d4c0a9e 以降継続的に fail(PR #709 スコープ外) |
Blockers
なし(人間判断が必要な mechanical: false なブロッカーは検出されず)
Non-blockers(任意改善)
- e2e baseline 不一致(
m2-running-hud-baseline.png)は main ブランチでも継続的に発生している既存問題。PR #709 の変更(SortieResult 型変更)は e2e テストに直接関係しない(tests/e2e/は Allowed Paths 外・Out of Scope)。follow-up で対応推奨。
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: REQUEST_CHANGES
reviewed_head_sha: ad38e8990312da408fb3d8e37f75632e76800a83
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: UNSTABLE
blockers: []
required_auto_actions:
- kind: update_pr_body_hygiene
executor: implementation-worker
skill: open-pr.update_pr
blocking_merge_ready: true
mechanical: true
note: "PR 本文の日本語比率不足(CI: PR Body Japanese Check fail)。Summary/Checks/Schema Change Applicability/Safety Claim Matrix/Notes の英語のみのセクションに日本語説明を追加する。"
auto_fix_applied: []
follow_up_issue_requests:
- title: "E2E visual regression: m2-running-hud-baseline.png baseline 更新(PR #704 baseline 追加後の継続 fail 解消)"
issue_kind: implementation
severity: mandatory_follow_up
blocking_merge_ready: false
source:
kind: pr_review
url: "https://github.com/squne121/loop-protocol/pull/709"
note_id: "1"
dedupe_key: "follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/pull/709:1"
desired_destination: "main ブランチの e2e CI が green になり、PR #704 で追加した baseline が正しく更新される。"
validated_scope_delta: "tests/e2e/__screenshots__/ の m2-running-hud-baseline.png を最新の実装に合わせて更新する。main ブランチで継続する toHaveScreenshot 失敗を解消する。"
origin_skill: pr-review-judge
labels:
- triage-required
initial_label_profile: "enhancement"
materialization: "pending"
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=UNSTABLE(e2e fail による UNSTABLE: PR #709 スコープ外の既存問題)
Evidence Check
- AC coverage: AC1〜AC11 について Summary・Checks セクションで達成が記述されている。AC9 は
pr_review_onlyスコープで guard 維持を確認済み(src/systems/SortieSystem.tsのenemies.length > 0guard)。 - Allowed Paths: 変更ファイル 4 件(
docs/product/features/sortie.md,src/state/GameState.ts,src/systems/SortieSystem.ts,tests/sortie-system.test.ts)がすべて Issue #680 の Allowed Paths に含まれる。スコープ外変更なし。 - CI Verification: CI run 27061826472(head_sha=ad38e8990312da408fb3d8e37f75632e76800a83、PR head_sha と一致)で typecheck/test/lint/build/python-test/actionlint がすべて conclusion=success。e2e のみ failure だが、main ブランチの直近マージ済み PR #707(run 27061175145)でも e2e が failure であり、PR #709 スコープ外の既存問題と確認済み(Out of Scope:
tests/e2e/)。CI_CHECK_RUN_SCOPED 条件(head_sha 一致・conclusion=success・VC 対応)を満たす。 - 検証コマンド結果:
## Checksセクションで typecheck/lint/test/build がすべて[x]チェック済み(406 tests PASS)。CI_CHECK_RUN_SCOPED で独立確認済み。 - Schema Change Applicability:
not_schema_changeを明示。TypeScript 内部型の discriminated union 化であり外部 JSON schema / 永続化 schema への影響なし。根拠が diff と一致。Schema Consumer Inventory 提出不要。 - Safety Claim Matrix: N/A 理由が妥当(auth/permission/sandbox/transport に非該当)。
- Runtime Verification:
decision: not_applicable(unit test/typecheck/build のみ。ブラウザ実行不要)。Runtime Verification Evidence 不要。
Blockers
なし
Non-blockers(任意改善)
- e2e テスト(
tests/e2e/)が main ブランチでも継続的に fail している。PR #709 スコープ外だが、後続 Issue でのベースライン修正が望ましい。
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: ad38e8990312da408fb3d8e37f75632e76800a83
merge_ready: true
mergeability:
mergeable: MERGEABLE
merge_state_status: UNSTABLE
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests:
- title: "e2e テストの既存 fail を修正し CI を安定させる"
issue_kind: implementation
severity: optional_follow_up
blocking_merge_ready: false
source:
kind: pr_review
url: "https://github.com/squne121/loop-protocol/pull/709"
note_id: "1"
dedupe_key: "follow-up:squne121/loop-protocol:https://github.com/squne121/loop-protocol/pull/709:1"
desired_destination: "main ブランチの e2e CI が安定的に pass し、UNSTABLE 状態が解消される"
validated_scope_delta: "tests/e2e/ の既存 fail 原因を調査・修正する"
origin_skill: pr-review-judge
labels:
- triage-required
initial_label_profile: implementation
materialization: pending
Verdict: REQUEST_CHANGES現状は merge 不可。実装の方向性自体は悪くありません。 ただし、PR #709 は Issue #680 の契約とズレています。このまま merge すると「Issue は満たしたことになっているが、AC と Allowed Paths を破っている」状態になります。 なお、この環境からの 致命的ブロッカー1. Issue #680 の AC1 と PR 実装が不一致PR #709 は 'all_enemies_defeated' | 'player_hp_zero' | 'timeout'一方、Issue #680 は PR 本文は 修正は二択です。 A. #680 の契約を守る場合 export type SortieEndReason =
| 'all_enemies_defeated'
| 'player_hp_zero'
| 'timeout'
| 'survival_timer'
export type SortieResult =
| (SortieResultBase & {
readonly outcome: 'victory'
readonly endReason: 'all_enemies_defeated' | 'survival_timer'
})
| (SortieResultBase & {
readonly outcome: 'defeat'
readonly endReason: 'player_hp_zero' | 'timeout'
})この場合、 B. 3値にする場合 先に Issue #680 を更新し、AC1、Outcome、提案型、 2. Allowed Paths 違反Issue #680 の Allowed Paths は次の3ファイルだけです。 しかし PR #709 は この doc 変更自体は技術的には妥当です。#483 / #489 では 修正案: または、doc 変更を別 Issue / 別 PR に分離してください。今回は型契約の意味を説明するため doc 更新は必要なので、#680 側を更新する方が自然です。 3. 既存レビューコメントの Allowed Paths 判定が信用できないPR 上の既存レビューは、 したがって、既存の APPROVE コメントはそのまま採用しない方がよいです。少なくとも「現在の Issue 本文に対する再評価」が必要です。 重要な改善点4.
|
SortieResult satisfies による compile-time 検証を tests/sortie-system.test.ts に追加。 valid 3 件(victory/defeat-hp-zero/defeat-timeout)と @ts-expect-error 3 件(不正な outcome×endReason 組み合わせ)を網羅する。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES
Mergeability
- mergeable=MERGEABLE, merge_state_status=BLOCKED(branch protection / CI failure)
Evidence Check
- AC coverage: AC1〜AC11 の内容は diff 上概ね充足。ただし AC11(
pnpm lintPASS)が CI で否決。 - Allowed Paths: 完全遵守(
docs/product/features/sortie.md/src/state/GameState.ts/src/systems/SortieSystem.ts/tests/sortie-system.test.tsの 4 ファイルのみ、全て Allowed Paths に含まれる) - CI Verification: head SHA
2e5ac9bでlintjob が失敗(run 27062371866、job 79877255222)。deploy-prも lint 失敗により連鎖失敗。typecheck/build/testはいずれも success。 - 検証コマンド結果: TEST_VERDICT_MACHINE コメント未投稿。PR 本文は self-report のみ(
PR_BODY_SELF_REPORT_ONLY_APPROVE_PROHIBITEDにより APPROVE の根拠として不十分)。
Blockers
- [CI lint failure / AC11 未達成] head SHA
2e5ac9bの lint job が ESLintno-unused-varsエラーで失敗している。tests/sortie-system.test.tslines 390, 399, 408, 418, 428, 438 — commit2e5ac9bで追加した型退行テスト用 fixture 変数(_validVictory,_validDefeatByHpZero,_validDefeatByTimeout,_invalidVictoryByHpZero,_invalidVictoryByTimeout,_invalidDefeatByAllEnemiesDefeated)が assigned but never used とみなされている。@ts-expect-error行の型エラーを発生させる用途であれば、変数宣言にvoidを付けるか、ESLint disable コメントを追加するか、_prefix 変数を ESLintno-unused-varsの ignore pattern に含める対応が必要。- AC11 の
pnpm lintPASS が Issue contract の必須 AC であり、CI fail は APPROVE 禁止条件に該当する。
Non-blockers
- なし
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: REQUEST_CHANGES
reviewed_head_sha: 2e5ac9b8a91b895191a427585eb6bc78501a15fd
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: BLOCKED
blockers:
- id: lint_failure_ac11
description: "pnpm lint が head SHA 2e5ac9b で失敗。tests/sortie-system.test.ts の型退行 fixture 変数 6件が no-unused-vars エラー(AC11 未達成)。"
mechanical: false
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []型退行テスト用 fixture 変数を変数宣言から void 式に変換し、 @typescript-eslint/no-unused-vars エラー 6 件を解消する。 Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=UNSTABLE(e2e visual regression baseline は main ブランチ起因・PR スコープ外)
Evidence Check
CI Verification(CI_CHECK_RUN_SCOPED、head_sha=68ff772930c7c70f64dbb934a14ccf5ecd3a69f9)
- lint: success
- typecheck: success
- test: success
- build: success
- python-test: success
- e2e: failure(
m2-running-hud-baseline.pngの visual regression、main ブランチでも同 SHA パターンで失敗中 — PR 変更とは無関係、Out of Scope: E2E テストの変更に合致)
TEST_VERDICT_MACHINE: 存在しない(CI_CHECK_RUN_SCOPED で代替。head_sha・workflow/job・conclusion 一致確認済み)
AC coverage:
- AC1:
docs/product/features/sortie.mdにendReasondiscriminated union 記述 — CI typecheck pass + diff 確認 - AC2:
src/state/GameState.tsにendReason: 'all_enemies_defeated'の discriminated union — diff 確認 - AC3:
SortieEndReasonは 3 値のみ(survival_timer除外は Issue #680 AC3 本文に明記済み) — diff 確認 - AC4:
endReason: 'player_hp_zero'テスト —tests/sortie-system.test.ts確認 - AC5:
endReason: 'timeout'テスト — 確認 - AC6:
endReason: 'all_enemies_defeated'テスト — 確認 - AC7: priority HP0 > 敵全滅 > timeout テスト — 確認
- AC8: 敵全滅 + timeout 同時 → victory テスト — 確認
- AC9:
state.enemies.lengthguard(pr_review_only VC)—SortieSystem.tsdiff でenemies.length > 0guard 維持確認 - AC10: double-result ラッチ +
endReason保持 —void Object.freeze({...} satisfies SortieResult)式形式で確認 - AC11: lint/typecheck/test/build — CI success
Allowed Paths 遵守: 変更ファイル 4 件(docs/product/features/sortie.md, src/state/GameState.ts, src/systems/SortieSystem.ts, tests/sortie-system.test.ts)はすべて Allowed Paths 内。逸脱なし。
Schema Change Applicability: not_schema_change 宣言あり、根拠が diff と一致(TypeScript 内部型のみ、外部 JSON schema / persistence schema 変更なし)。
Safety: safety-sensitive path 非該当、Safety Claim Matrix 不要の根拠適切。
Closing keyword: Closes #680 確認済み。
Blockers
なし
Non-blockers(任意改善)
なし
LOOP_VERDICT_V2
LOOP_VERDICT_V2:
verdict: APPROVE
reviewed_head_sha: 68ff772930c7c70f64dbb934a14ccf5ecd3a69f9
merge_ready: false
mergeability:
mergeable: MERGEABLE
merge_state_status: UNSTABLE
blockers: []
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
Summary
SortieResultを discriminated union に変更し、outcomeとendReasonの整合を型レベルで保証する。M2 runtime で発生しうる
endReasonはall_enemies_defeated/player_hp_zero/timeoutの 3 値のみ。SortieEndReason型(3 値)とSortieResultdiscriminated union をGameState.tsに追加SortieSystem.tsでendReasonを 3 分岐(HP ゼロ / 敵全滅 / timeout)で正しく設定sortie-system.test.tsに AC4〜AC8、AC10 のendReason検証テストを追加docs/product/features/sortie.mdのSortieResultshape 定義を discriminated union に更新(SSOT)Checks
pnpm typecheck— 型エラーなしpnpm lint— lint エラーなしpnpm test(406 tests PASS) — 全テスト通過pnpm build— ビルド成功Schema Change Applicability
src/main.tsの既存 consumer は.outcomeのみアクセスし型エラーなし(typecheck 確認済み)。スキーマ変更非該当。TypeScript 内部型の discriminated union 化であり、外部 JSON schema や永続化 schema への影響なし。
Schema Consumer Inventory
N/A — スキーマを変更しないため inventory は不要。既存 consumer への影響なし。
Safety Claim Matrix
N/A
reason: safety-sensitive path(auth / permission / secret)に該当しない。セキュリティ上の影響なし。
Notes
SortieEndReasonは M2 で到達不能なsurvival_timerを含まない(Issue spec/impl(#483): MVP sortie を敵機全滅勝利・30秒終了に変更する #542 で MVP 除外済み)src/main.tsは Allowed Paths 外だが.outcomeのみアクセスするため型エラーなしCloses #680(このプルリクエストは Issue #680 を解決します)