[PR #2045] [MERGED] Bound generation history hot-path reads #5406

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2034-bounded-generation-history


📝 Commits (1)

  • a327610 Bound generation history hot-path reads

📊 Changes

3 files changed (+98 additions, -14 deletions)

View changed files

📝 src/engine/generation/context.ts (+5 -0)
📝 src/engine/generation/start-generation.ts (+86 -13)
📝 src/engine/modes/chat/autonomous/autonomous.service.ts (+7 -1)

📄 Description

Linked issue

Closes #2034

Why this change

  • Generation, targeted retry/lorebook keeper, and autonomous background checks still had hot paths that could request full chat message history. Large chats could therefore make routine generation and polling scale with total transcript size instead of the prompt/activity window.

What changed

  • Normal generation now always passes a bounded message load limit that matches the prompt assembly default history window plus margin.
  • Regeneration and targeted agent retry fetch the target message by id, then load only the bounded page before that target cursor.
  • Lorebook keeper backfill now scans lightweight message metadata to find candidate targets, then hydrates only each target's bounded generation context.
  • Autonomous activity initialization now requests only a recent projected message slice with role, createdAt, and characterId.

Refactor impact

Primary owner:

  • engine generation

Impact areas reviewed:

  • startGeneration normal and regenerate message loading
  • retryGenerationAgents targeted and lorebook keeper paths
  • autonomous conversation activity initialization
  • storage message pagination/projection behavior

Boundary notes:

  • Engine-only change. No React, shared API wrapper, Tauri command, schema, dependency, version, import/export, or release metadata changes.
  • Storage remains the consumer contract; callers now pass bounded/projected options instead of relying on unbounded defaults.

Pressure points touched:

  • src/engine/generation/start-generation.ts
  • src/engine/generation/context.ts
  • src/engine/modes/chat/autonomous/autonomous.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

  • pnpm exec vitest run --config scratch\vitest.issue-2034.config.ts passed. The scratch proof asserts normal generation limit 320, regenerate and targeted retry before cursor pages, lorebook keeper metadata scan without content payload plus bounded target context, and autonomous activity limit 80 with role/createdAt/characterId fields.
  • pnpm check passed on current upstream/refactor: line endings, architecture, frontend tsc -b, Rust workspace cargo check, docs, discovery metadata, and unused-code.
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny review pass completed before opening this draft. No blocking findings.
  • No separate human-only verification is required for the core claim; this is an engine read-shape change proven by the scratch harness and full repo check.
  • Non-blocking note: lorebook keeper candidate scans avoid reading full message content. Blank assistant targets are skipped after target hydration, which preserves the no-empty-target guard without restoring full-payload scans.

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:

  • Internal engine performance/read-shape fix only; no new user-discoverable feature or workflow.

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; no visible UI changes.


🔄 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/2045 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/3/2026 **Status:** ✅ Merged **Merged:** 6/3/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-2034-bounded-generation-history` --- ### 📝 Commits (1) - [`a327610`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a327610b89c4f283ebe17ff4934074f25eb71d52) Bound generation history hot-path reads ### 📊 Changes **3 files changed** (+98 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/context.ts` (+5 -0) 📝 `src/engine/generation/start-generation.ts` (+86 -13) 📝 `src/engine/modes/chat/autonomous/autonomous.service.ts` (+7 -1) </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 Closes #2034 ## Why this change - Generation, targeted retry/lorebook keeper, and autonomous background checks still had hot paths that could request full chat message history. Large chats could therefore make routine generation and polling scale with total transcript size instead of the prompt/activity window. ## What changed - Normal generation now always passes a bounded message load limit that matches the prompt assembly default history window plus margin. - Regeneration and targeted agent retry fetch the target message by id, then load only the bounded page before that target cursor. - Lorebook keeper backfill now scans lightweight message metadata to find candidate targets, then hydrates only each target's bounded generation context. - Autonomous activity initialization now requests only a recent projected message slice with `role`, `createdAt`, and `characterId`. ## Refactor impact Primary owner: - engine generation Impact areas reviewed: - `startGeneration` normal and regenerate message loading - `retryGenerationAgents` targeted and lorebook keeper paths - autonomous conversation activity initialization - storage message pagination/projection behavior Boundary notes: - Engine-only change. No React, shared API wrapper, Tauri command, schema, dependency, version, import/export, or release metadata changes. - Storage remains the consumer contract; callers now pass bounded/projected options instead of relying on unbounded defaults. Pressure points touched: - `src/engine/generation/start-generation.ts` - `src/engine/generation/context.ts` - `src/engine/modes/chat/autonomous/autonomous.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 - `pnpm exec vitest run --config scratch\vitest.issue-2034.config.ts` passed. The scratch proof asserts normal generation limit `320`, regenerate and targeted retry `before` cursor pages, lorebook keeper metadata scan without `content` payload plus bounded target context, and autonomous activity limit `80` with `role`/`createdAt`/`characterId` fields. - `pnpm check` passed on current `upstream/refactor`: line endings, architecture, frontend `tsc -b`, Rust workspace `cargo check`, docs, discovery metadata, and unused-code. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny review pass completed before opening this draft. No blocking findings. - No separate human-only verification is required for the core claim; this is an engine read-shape change proven by the scratch harness and full repo check. - Non-blocking note: lorebook keeper candidate scans avoid reading full message content. Blank assistant targets are skipped after target hydration, which preserves the no-empty-target guard without restoring full-payload scans. ## 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: - Internal engine performance/read-shape fix only; no new user-discoverable feature or workflow. ## 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; no visible UI changes. --- <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:02 +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#5406
No description provided.