mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2035] Lorebook activation scans re-read entries once per active book #997
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#997
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Xelvanis on GitHub (Jun 3, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2035
Originally assigned to: @cha1latte on GitHub.
Problem
Lorebook activation reads currently scan the entry collection once per active lorebook.
Current refactor evidence on
origin/refactor:src/engine/generation/active-lorebook-scanner.ts:525lists all lorebooks, then filters active/scoped books.src/engine/generation/active-lorebook-scanner.ts:558-560maps each active lorebook throughloadLorebookEntriesForActivation.src/engine/generation/active-lorebook-scanner.ts:419-426callsstorage.listLorebookEntries(id)for one lorebook at a time.src/shared/api/storage-api.tsimplementslistLorebookEntriesas a filteredstorage.list("lorebook-entries", { filters: { lorebookId } }), so each active book re-enters the generic list/filter path.src-tauri/crates/storage/src/lib.rs:100exposeslist_where; on uncached file storage this scans the collection file.Legacy had a batched shape for this class of work:
origin/main:packages/server/src/services/storage/lorebooks.storage.ts:321-328lists entries by multiple lorebook IDs in one query.origin/main:packages/server/src/services/storage/lorebooks.storage.ts:409-411reads enabled entries for active books with oneinArray(lorebookId, bookIds)query.Scratch large-profile timing on the current Target 2 batch 4 base, using synthetic JSON collections:
215.76mscold /20.22mswarm,1,311,385payload bytes.This affects generation prompt assembly, active lorebook info, built-in lorebook search, and any runtime path that scans active lore.
Expected
Activation should read eligible entries for all active lorebooks in one storage call, then group in memory. The cost should scale with one collection scan, not one scan per active book.
Suggested Fix
listLorebookEntriesByLorebookIds(ids)using the existing projected/where-in backend shape.