[PR #2216] [MERGED] Fix game combat LLM initialization #5479

Closed
opened 2026-10-22 04:16:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2216
Author: @cha1latte
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-2136-game-combat-llm-init


📝 Commits (8)

  • 98c4764 Fix game combat LLM initialization
  • 904c042 Address combat init review feedback
  • f1b0e66 Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init
  • 48efad2 Fix Rust clippy row tuple alias
  • 183db67 Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init
  • f9ef98c Preserve explicit empty combat item effects
  • 98facf9 Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init
  • 6bb8d1c Resolve storage row alias merge drift

📊 Changes

3 files changed (+936 additions, -84 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+0 -4)
➕ src/engine/modes/game/mechanics/combat-init.service.ts (+911 -0)
📝 src/features/modes/game/api/game-api.ts (+25 -80)

📄 Description

Linked issue

Closes #2136

Why this change

  • Game-mode combat initialization was still using a deterministic placeholder builder, so generated encounters ignored the selected LLM connection, game cards, inventory, spellbook context, chat history, mechanics, dialogue cues, and visual prompts.

What changed

  • Added a game-owned combat init service that builds an LLM blueprint prompt from game cards, persona context, world state, inventory, spellbook entries, and recent chat history.
  • Routed gameApi.initCombatEncounter through that service instead of constructing Enemy N placeholder combatants inline.
  • Kept a sanitized fallback combat state for malformed/unavailable model output, while the normal path now calls the configured LLM and preserves generated enemies, party actions, item effects, mechanics, dialogue cues, and visuals.

Refactor impact

Primary owner:

  • Game mode, engine generation

Impact areas reviewed:

  • Game combat initialization, LLM connection selection, spellbook injection, game-card prompt context, combat state sanitization, architecture import boundaries

Boundary notes:

  • Engine code stays React/Tauri-adapter-free and uses StorageGateway/LlmGateway.
  • Feature code calls the game-owned engine service through existing storageApi and llmApi wrappers.
  • Game mode does not import roleplay mode.

Pressure points touched:

  • src/features/modes/game/api/game-api.ts
  • src/engine/modes/game/mechanics/combat-init.service.ts

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex focused repro before fix: pnpm vitest run --config scratch/vitest.config.ts --reporter=verbose confirmed game combat init returned Enemy 1/Enemy 2, empty mechanics/visuals, and did not call llmApi.complete.
  • Codex focused repro after fix: pnpm vitest run --config scratch/vitest.config.ts --reporter=verbose confirmed game combat init calls llmApi.complete, honors the selected/chat connection paths, includes spellbook/world/party/game-card fields in the prompt, and returns generated enemy attacks, mechanics, dialogue cues, and visuals.
  • Codex baseline: pnpm check passed on origin/refactor@4bcc5db5.
  • Bunny review: passed locally; the configured proof-gate helper was unavailable at C:\Users\celia\.codex\tools\marinara-proof-gate.mjs.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix for existing game-mode combat generation behavior; no new discoverable surface.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

  • N/A for visible UI screenshots; this is game API/engine behavior. Local non-UI proof screenshot: scratch/game-combat-init-proof.png.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2216 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2136-game-combat-llm-init` --- ### 📝 Commits (8) - [`98c4764`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98c4764cb497b76f9f393550a5f20456d3d06271) Fix game combat LLM initialization - [`904c042`](https://github.com/Pasta-Devs/Marinara-Engine/commit/904c042af74619aeabcb1f06702c252ecce4f6c7) Address combat init review feedback - [`f1b0e66`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f1b0e6618dae915faa8f1d56001af883071cdbf7) Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init - [`48efad2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/48efad282780af15626aa1fb2d396bb64fb4cc35) Fix Rust clippy row tuple alias - [`183db67`](https://github.com/Pasta-Devs/Marinara-Engine/commit/183db676f48904a51cd2d326a58ea75cc81e45d5) Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init - [`f9ef98c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f9ef98ca47b07e799354e0ac887700755a4db1b6) Preserve explicit empty combat item effects - [`98facf9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98facf92a29a2bb9d0f391fa5706aa8ed8ad3b00) Merge remote-tracking branch 'origin/refactor' into fix/issue-2136-game-combat-llm-init - [`6bb8d1c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6bb8d1c80757fed219b40049ea7b267e23cd67cf) Resolve storage row alias merge drift ### 📊 Changes **3 files changed** (+936 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+0 -4) ➕ `src/engine/modes/game/mechanics/combat-init.service.ts` (+911 -0) 📝 `src/features/modes/game/api/game-api.ts` (+25 -80) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #2136 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Game-mode combat initialization was still using a deterministic placeholder builder, so generated encounters ignored the selected LLM connection, game cards, inventory, spellbook context, chat history, mechanics, dialogue cues, and visual prompts. ## What changed <!-- List the key changes in this PR. --> - Added a game-owned combat init service that builds an LLM blueprint prompt from game cards, persona context, world state, inventory, spellbook entries, and recent chat history. - Routed `gameApi.initCombatEncounter` through that service instead of constructing `Enemy N` placeholder combatants inline. - Kept a sanitized fallback combat state for malformed/unavailable model output, while the normal path now calls the configured LLM and preserves generated enemies, party actions, item effects, mechanics, dialogue cues, and visuals. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> - Game mode, engine generation Impact areas reviewed: - Game combat initialization, LLM connection selection, spellbook injection, game-card prompt context, combat state sanitization, architecture import boundaries Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Engine code stays React/Tauri-adapter-free and uses `StorageGateway`/`LlmGateway`. - Feature code calls the game-owned engine service through existing `storageApi` and `llmApi` wrappers. - Game mode does not import roleplay mode. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `src/features/modes/game/api/game-api.ts` - `src/engine/modes/game/mechanics/combat-init.service.ts` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex focused repro before fix: `pnpm vitest run --config scratch/vitest.config.ts --reporter=verbose` confirmed game combat init returned `Enemy 1`/`Enemy 2`, empty mechanics/visuals, and did not call `llmApi.complete`. - Codex focused repro after fix: `pnpm vitest run --config scratch/vitest.config.ts --reporter=verbose` confirmed game combat init calls `llmApi.complete`, honors the selected/chat connection paths, includes spellbook/world/party/game-card fields in the prompt, and returns generated enemy attacks, mechanics, dialogue cues, and visuals. - Codex baseline: `pnpm check` passed on `origin/refactor@4bcc5db5`. - Bunny review: passed locally; the configured proof-gate helper was unavailable at `C:\Users\celia\.codex\tools\marinara-proof-gate.mjs`. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix for existing game-mode combat generation behavior; no new discoverable surface. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> - N/A for visible UI screenshots; this is game API/engine behavior. Local non-UI proof screenshot: `scratch/game-combat-init-proof.png`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:41 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5479
No description provided.