[PR #1499] [MERGED] Triage Knip unused files and restore refactor add-backs #5112

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1499
Author: @Xelvanis
Created: 5/29/2026
Status: ✅ Merged
Merged: 5/29/2026
Merged by: @SpicyMarinara

Base: refactor ← Head: chore/knip-unused-triage


📝 Commits (4)

  • 1c8d64a chore: triage knip unused files
  • ebec875 fix: harden fail paths after rebase
  • ac9f1ef fix: address bunny review findings
  • 6a6f372 Merge remote-tracking branch 'origin/refactor' into pr-1499

📊 Changes

51 files changed (+9201 additions, -5490 deletions)

View changed files

📝 graphify-out/.graphify_labels.json (+16 -5)
📝 graphify-out/GRAPH_REPORT.md (+354 -285)
➕ graphify-out/cache/ast/24106c885ca18b21081c9790efa645dba1f91693a539dcad0474226f662ab71d.json (+1 -0)
➕ graphify-out/cache/ast/4ebc6999adc9e47e7a5ef558ae4967c1fe318394436e8a2dbeaa3966d5235afb.json (+1 -0)
➕ graphify-out/cache/ast/64d00c964159d5719a02ae63629b74017066ab906071bee189fcab6fe1008bf1.json (+1 -0)
➕ graphify-out/cache/ast/cf4b206ebb89479927167c7761584d578b529818c61c8e516487134233aa5ad3.json (+1 -0)
➕ graphify-out/cache/ast/d95d1411b397ad74514af17753324918394beaf03873f3a9962edeb9f3825bf1.json (+1 -0)
➕ graphify-out/cache/ast/db440d0ef37bb596befa3b6596cc270a1f80fe67a8e1cbb0a84e363f3c9c9748.json (+1 -0)
➕ graphify-out/cache/ast/dcb0caed151f8eb532a729cb7c7cc58cde65a9e2031465e7d2209bba73738ae6.json (+1 -0)
📝 graphify-out/cache/stat-index.json (+1 -1)
📝 graphify-out/graph.json (+6193 -3691)
📝 graphify-out/manifest.json (+1199 -1189)
📝 knip.json (+4 -16)
📝 package.json (+1 -1)
📝 src/app/shell/ChatSidebar.tsx (+7 -6)
📝 src/app/shell/useStartNewChat.ts (+2 -7)
📝 src/engine/agents-runtime/knowledge/knowledge-retrieval.ts (+17 -3)
📝 src/engine/agents-runtime/pipeline/agent-pipeline.ts (+44 -13)
📝 src/engine/contracts/constants/chat-modes.ts (+1 -1)
📝 src/engine/contracts/schemas/app-settings.schema.ts (+5 -5)

...and 31 more files

📄 Description

Linked issue

Refs #1496

Why this change

  • Knip was reporting a broad unused-code/dependency surface on refactor, but several entries were not safe-delete cleanup. Some were refactor parity gaps where useful helpers or feature paths existed but were not wired back into the active runtime.
  • This PR restores the low-risk add-backs that have a clear current owner path, records the remaining unsafe-to-delete set, and narrows the Knip unused-file list for follow-up owner decisions.

What changed

  • Scoped knip.json to source/config entrypoints and ignored tool dependencies that are invoked outside normal imports (@tauri-apps/cli, tailwindcss).
  • Updated pnpm check:unused to run Knip in report-only mode with --no-exit-code --no-config-hints, matching the triage workflow for this branch.
  • Restored engine add-backs for generation IDs/clock, impersonation prompt selection, game lorebook scoping, session summary normalization, party prompts, NPC avatar normalization, perception hints, knowledge retrieval/router agents, schema-boundary parsing, and export type reuse.
  • Restored UI/runtime add-backs for shared chat attachment image prep, page-activity-aware conversation refresh, chat mode constants, and Game Mode party-turn handling.
  • Moved game scene-analysis helpers out of the roleplay owner into src/engine/modes/game/scene, then wired analyzeGameScene through the richer prompt and post-processing path.
  • Hardened the rebased failure paths: disabled game lorebook-keeper sources no longer run retrieval, malformed scene-analysis fields are sanitized, local scene music/ambient hints are scored again, and party-turn failures/malformed output no longer persist fake [party-turn] messages.
  • Preserved unknown embedded character-book fields when parsing imported/updated character cards.
  • Added focused regression coverage for the restored game/generation paths, party-turn failure handling, scene-analysis sanitization, and character-book passthrough behavior.
  • Refreshed Graphify after the rebase and final code changes.

Refactor impact

Primary owner:

  • Engine generation, Game Mode, catalog mutation hooks, conversation input/runtime UI, shared API contracts, and Graphify map output.

Impact areas reviewed:

  • Generation prompt assembly, agent runtime routing, Game Mode party-turn persistence/error handling, Game Mode scene analysis/audio post-processing, catalog create/update payload boundaries, conversation refresh cadence, chat attachment preparation, and Knip output.

Boundary notes:

  • Engine code stays React-free and uses capability ports for LLM/storage scene analysis.
  • The game scene analyzer now lives under the Game Mode owner instead of importing game behavior from the roleplay scene folder.
  • Feature hooks parse payloads through engine contract schemas but still call existing shared API/storage wrappers.
  • No dependency or lockfile changes are included; package.json only changes the check:unused script.

Pressure points touched:

  • GameSurface, GameNarration, game scene analysis service, generation prompt assembly, catalog hooks, shared chat input components, Knip config/script, and Graphify output.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • pnpm typecheck passed on the rebased head.
  • Focused Vitest batch passed on the rebased head: src/engine/generation/agent-runner.test.ts, src/engine/generation/prompt-assembly.test.ts, src/engine/generation/start-generation.test.ts, src/engine/modes/game/scene/game-scene-analysis.service.test.ts, src/features/modes/game/api/game-api.test.ts, src/features/catalog/characters/hooks/use-characters.test.ts (6 files, 140 tests).
  • pnpm build passed on the rebased head with the existing large-chunk warning.
  • pnpm check:architecture passed on the rebased head.
  • pnpm check:unused passed on the rebased head. It now runs knip --no-exit-code --no-config-hints and still reports the intentional unused-code/dependency/export inventory for follow-up triage, including 16 unused files.
  • graphify update . passed with Graphify 0.8.21; graph.html was skipped because the graph exceeds the configured visualization limit, while graph.json and GRAPH_REPORT.md were updated.
  • pnpm check:docs passed on the rebased head.
  • git diff --check origin/refactor...HEAD passed.
  • Not run on the rebased head: full pnpm check, pnpm lint:eslint, Rust cargo checks, native Tauri UI QA, browser/Playwright UI evidence, and remote-runtime smoke. No Rust files are changed in this PR.

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

  • No CHANGELOG.md exists in this checkout.

  • No public docs were changed; the remaining Knip cleanup decisions are tracked in #1496.

UI evidence

  • No screenshots or recordings added.
  • This includes UI-path wiring, but the proof here is static/build/focused test coverage rather than a native Tauri pass.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added party turn system enabling group conversations within game mode.
    • Integrated game perception hints into GM prompts for enhanced storytelling context.
  • Improvements

    • Enhanced game scene analysis with improved validation and error handling.
    • Unified image attachment handling across all input methods.
    • Improved knowledge retrieval with empty material handling.
    • Added page activity detection to optimize status refresh frequency.
  • Bug Fixes

    • Fixed NPC avatar sanitization in game mode.
    • Corrected party turn message detection and filtering.
  • Chores

    • Added comprehensive schema validation across data mutations.
    • Expanded test coverage for game features and lorebook functionality.

Review Change Stack


🔄 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/1499 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/29/2026 **Status:** ✅ Merged **Merged:** 5/29/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `refactor` ← **Head:** `chore/knip-unused-triage` --- ### 📝 Commits (4) - [`1c8d64a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1c8d64a84674531068f4b117bfbb2b48226947ec) chore: triage knip unused files - [`ebec875`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ebec8755b025462176108c83e87378e547e62adc) fix: harden fail paths after rebase - [`ac9f1ef`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac9f1ef116c23774f4aadbdecca1b7b6f6060894) fix: address bunny review findings - [`6a6f372`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a6f3724cc31ca3392fea7a76f77da562554da6a) Merge remote-tracking branch 'origin/refactor' into pr-1499 ### 📊 Changes **51 files changed** (+9201 additions, -5490 deletions) <details> <summary>View changed files</summary> 📝 `graphify-out/.graphify_labels.json` (+16 -5) 📝 `graphify-out/GRAPH_REPORT.md` (+354 -285) ➕ `graphify-out/cache/ast/24106c885ca18b21081c9790efa645dba1f91693a539dcad0474226f662ab71d.json` (+1 -0) ➕ `graphify-out/cache/ast/4ebc6999adc9e47e7a5ef558ae4967c1fe318394436e8a2dbeaa3966d5235afb.json` (+1 -0) ➕ `graphify-out/cache/ast/64d00c964159d5719a02ae63629b74017066ab906071bee189fcab6fe1008bf1.json` (+1 -0) ➕ `graphify-out/cache/ast/cf4b206ebb89479927167c7761584d578b529818c61c8e516487134233aa5ad3.json` (+1 -0) ➕ `graphify-out/cache/ast/d95d1411b397ad74514af17753324918394beaf03873f3a9962edeb9f3825bf1.json` (+1 -0) ➕ `graphify-out/cache/ast/db440d0ef37bb596befa3b6596cc270a1f80fe67a8e1cbb0a84e363f3c9c9748.json` (+1 -0) ➕ `graphify-out/cache/ast/dcb0caed151f8eb532a729cb7c7cc58cde65a9e2031465e7d2209bba73738ae6.json` (+1 -0) 📝 `graphify-out/cache/stat-index.json` (+1 -1) 📝 `graphify-out/graph.json` (+6193 -3691) 📝 `graphify-out/manifest.json` (+1199 -1189) 📝 `knip.json` (+4 -16) 📝 `package.json` (+1 -1) 📝 `src/app/shell/ChatSidebar.tsx` (+7 -6) 📝 `src/app/shell/useStartNewChat.ts` (+2 -7) 📝 `src/engine/agents-runtime/knowledge/knowledge-retrieval.ts` (+17 -3) 📝 `src/engine/agents-runtime/pipeline/agent-pipeline.ts` (+44 -13) 📝 `src/engine/contracts/constants/chat-modes.ts` (+1 -1) 📝 `src/engine/contracts/schemas/app-settings.schema.ts` (+5 -5) _...and 31 more files_ </details> ### 📄 Description ## Linked issue Refs #1496 ## Why this change - Knip was reporting a broad unused-code/dependency surface on `refactor`, but several entries were not safe-delete cleanup. Some were refactor parity gaps where useful helpers or feature paths existed but were not wired back into the active runtime. - This PR restores the low-risk add-backs that have a clear current owner path, records the remaining unsafe-to-delete set, and narrows the Knip unused-file list for follow-up owner decisions. ## What changed - Scoped `knip.json` to source/config entrypoints and ignored tool dependencies that are invoked outside normal imports (`@tauri-apps/cli`, `tailwindcss`). - Updated `pnpm check:unused` to run Knip in report-only mode with `--no-exit-code --no-config-hints`, matching the triage workflow for this branch. - Restored engine add-backs for generation IDs/clock, impersonation prompt selection, game lorebook scoping, session summary normalization, party prompts, NPC avatar normalization, perception hints, knowledge retrieval/router agents, schema-boundary parsing, and export type reuse. - Restored UI/runtime add-backs for shared chat attachment image prep, page-activity-aware conversation refresh, chat mode constants, and Game Mode party-turn handling. - Moved game scene-analysis helpers out of the roleplay owner into `src/engine/modes/game/scene`, then wired `analyzeGameScene` through the richer prompt and post-processing path. - Hardened the rebased failure paths: disabled game lorebook-keeper sources no longer run retrieval, malformed scene-analysis fields are sanitized, local scene music/ambient hints are scored again, and party-turn failures/malformed output no longer persist fake `[party-turn]` messages. - Preserved unknown embedded character-book fields when parsing imported/updated character cards. - Added focused regression coverage for the restored game/generation paths, party-turn failure handling, scene-analysis sanitization, and character-book passthrough behavior. - Refreshed Graphify after the rebase and final code changes. ## Refactor impact Primary owner: - Engine generation, Game Mode, catalog mutation hooks, conversation input/runtime UI, shared API contracts, and Graphify map output. Impact areas reviewed: - Generation prompt assembly, agent runtime routing, Game Mode party-turn persistence/error handling, Game Mode scene analysis/audio post-processing, catalog create/update payload boundaries, conversation refresh cadence, chat attachment preparation, and Knip output. Boundary notes: - Engine code stays React-free and uses capability ports for LLM/storage scene analysis. - The game scene analyzer now lives under the Game Mode owner instead of importing game behavior from the roleplay scene folder. - Feature hooks parse payloads through engine contract schemas but still call existing shared API/storage wrappers. - No dependency or lockfile changes are included; `package.json` only changes the `check:unused` script. Pressure points touched: - `GameSurface`, `GameNarration`, game scene analysis service, generation prompt assembly, catalog hooks, shared chat input components, Knip config/script, and Graphify output. ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes - `pnpm typecheck` passed on the rebased head. - Focused Vitest batch passed on the rebased head: `src/engine/generation/agent-runner.test.ts`, `src/engine/generation/prompt-assembly.test.ts`, `src/engine/generation/start-generation.test.ts`, `src/engine/modes/game/scene/game-scene-analysis.service.test.ts`, `src/features/modes/game/api/game-api.test.ts`, `src/features/catalog/characters/hooks/use-characters.test.ts` (`6` files, `140` tests). - `pnpm build` passed on the rebased head with the existing large-chunk warning. - `pnpm check:architecture` passed on the rebased head. - `pnpm check:unused` passed on the rebased head. It now runs `knip --no-exit-code --no-config-hints` and still reports the intentional unused-code/dependency/export inventory for follow-up triage, including `16` unused files. - `graphify update .` passed with Graphify `0.8.21`; `graph.html` was skipped because the graph exceeds the configured visualization limit, while `graph.json` and `GRAPH_REPORT.md` were updated. - `pnpm check:docs` passed on the rebased head. - `git diff --check origin/refactor...HEAD` passed. - Not run on the rebased head: full `pnpm check`, `pnpm lint:eslint`, Rust cargo checks, native Tauri UI QA, browser/Playwright UI evidence, and remote-runtime smoke. No Rust files are changed in this PR. ## 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 - No `CHANGELOG.md` exists in this checkout. - No public docs were changed; the remaining Knip cleanup decisions are tracked in #1496. ## UI evidence - No screenshots or recordings added. - This includes UI-path wiring, but the proof here is static/build/focused test coverage rather than a native Tauri pass. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added party turn system enabling group conversations within game mode. * Integrated game perception hints into GM prompts for enhanced storytelling context. * **Improvements** * Enhanced game scene analysis with improved validation and error handling. * Unified image attachment handling across all input methods. * Improved knowledge retrieval with empty material handling. * Added page activity detection to optimize status refresh frequency. * **Bug Fixes** * Fixed NPC avatar sanitization in game mode. * Corrected party turn message detection and filtering. * **Chores** * Added comprehensive schema validation across data mutations. * Expanded test coverage for game features and lorebook functionality. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1499?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:24 +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#5112
No description provided.