# Task E4 — Pet Companion Commands and Support ## Scope Implemented E4 only: - Optional pet-enabled runs spawn one run-scoped moth companion beside the player, render it in the live `Game` scene, and keep its visual state synchronized after actions and defeat. - The `K` companion command opens a keyboard-operable panel (`←`/`→`, `Esc`) with explicit **Follow**, **Defend**, and **Support** stances and journal events. - Deterministic companion policies follow without sharing the player/enemy cells, defend against adjacent threats, and support-intercept enemy melee while adjacent to the player. - A companion can fall without ending or blocking the player's run. - Added unit, integration, and real-input E2E coverage for state/stances, policies, support interception/death, visible spawning, and command input. No F1 character-progression behavior was integrated. ## Shared-XP boundary E4 provides a deliberately neutral earned-XP allocation seam, not progression: - On a player kill in a companion run, `TurnResolver` disables CombatEngine's legacy direct XP grant and calls `CompanionState.share_xp` exactly once. - The seam allocates the reward 50/50 (odd points favor the player), updates only the two earned-XP ledgers, and emits exactly one existing `xp_granted` journal descriptor with both allocations. - A fallen companion receives no share; the player receives the whole reward. - It does **not** read or mutate levels, thresholds, attributes, skills, unlocks, or any other F1-owned progression state. Combat without a companion retains the pre-E4 legacy XP path. This avoids the former subtract/re-add workaround and prevents duplicate XP mutation while preserving the journal contract. ## Final verification and capture Executed with Godot **4.5.0** (`/snap/bin/godot4`): ```text ./scripts/verify.sh PASS - Unit: 151 / 151 tests, 1,161 assertions - Integration: 10 / 10 tests, 59,462 assertions - E2E: 45 / 45 tests, 452 assertions - Visual: PASS — Xvfb initial and exit captures git diff --check PASS ``` The final visual run created and measured the ignored captures: ```text artifacts/visual-check.png: dungeon_non_black_pixels=489308, visible_pixels=17524, explored_pixels=10438, explored_luminance=0.012, unknown_pixels=366284, unknown_luminance=0.001 artifacts/visual-check-exit.png: dungeon_non_black_pixels=489252, visible_pixels=17404, explored_pixels=17146, explored_luminance=0.012, unknown_pixels=440456, unknown_luminance=0.001 ``` The known GUT invalid-UID warnings plus Godot `ObjectDB instances leaked` / resources-in-use exit diagnostics remain runner-environment noise. The final run had no `SCRIPT ERROR`, `Parse Error`, test failure, or visual-check failure. ## Git Report finalized before the local E4 commit. No push and no PR were created.