mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8786] [MERGED] fix(lorebooks): keep embedded and imported lorebook settings intact #8804
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#8804
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8786
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/lorebook-import-fidelity📝 Commits (2)
c44a698fix(lorebooks): keep embedded and imported lorebook settings intact3a58e67fix(lorebooks): import a collapsed-scope native lorebook as non-global📊 Changes
12 files changed (+485 additions, -51 deletions)
View changed files
📝
packages/server/src/routes/characters.routes.ts(+2 -5)📝
packages/server/src/routes/import.routes.ts(+2 -2)📝
packages/server/src/routes/lorebooks.routes.ts(+2 -16)📝
packages/server/src/services/import/marinara.importer.ts(+34 -15)📝
packages/server/src/services/import/st-character.importer.ts(+4 -2)📝
packages/server/src/services/import/st-lorebook.importer.ts(+61 -8)📝
packages/server/src/services/lorebook/character-book-sync.ts(+46 -3)📝
packages/shared/src/schemas/character.schema.ts(+1 -0)➕
scripts/regressions/character-book-fidelity.regression.ts(+143 -0)➕
scripts/regressions/json-card-bom-import.regression.ts(+54 -0)📝
scripts/regressions/lorebook-reimport-links.regression.ts(+43 -0)➕
scripts/regressions/native-lorebook-import-links.regression.ts(+93 -0)📄 Description
Linked issue
Closes #8785
Why this change
Everyday card and lorebook actions were quietly damaging lorebook settings. Saving a card in the Character editor turned Outlet entries into Before Char entries. SillyTavern/Chub cards imported with the wrong placement and triggers: @D entries landed After Char, probability gates were dropped, and NOT ANY became AND ANY. Their SillyTavern data was then erased from the card, so a Compatible export handed SillyTavern its defaults. Import/Reimport Embedded Lorebook reset the card's settings, and the user's lorebook name and settings, to import defaults. A native lorebook shared from another install could be hidden in every chat because its chat IDs belonged to that install. JSON cards saved with a BOM were rejected by the server even though the browser accepted them. None of these are new in this release. All came from a release-prep audit and were confirmed by two independent verifiers. No issue is linked yet; one should be opened before the PR is submitted.
What changed
extensions: @D position and depth, role, probability, selective logic, group and weight, sticky/cooldown/delay, scan depth, case and whole-word matching, the recursion flags, vectorized and outlet name.extensions, in SillyTavern's numbering, so Compatible character exports keep their placement and triggers in SillyTavern.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Agent-run checks (for reference; each regression was shown to fail without its fix):
node ./scripts/pnpm-runner.mjs build:shared: passed. Rebuilt again after the review fix; the dist contains z.literal(7).cd packages/server && npx tsc --noEmit: passed (no output), after the review fixnode ./scripts/pnpm-runner.mjs --filter @marinara-engine/server lint (tsc -b ../shared && tsc --noEmit && tsc -p tsconfig.character-activity.json): exit 0, after the review fixnode ./scripts/pnpm-runner.mjs --filter @marinara-engine/shared lint: exit 0 (first round; shared not touched in the review round)node_modules/.bin/prettier --write, then --check, on the changed files: --check exit 0. In this round --write left both changed files unchanged.eslint on changed files: Not run: only packages/client has an ESLint config, and no client files changed. The server and shared lint scripts (tsc) ran instead.pnpm localization:check: Not run: no client copy changed.node ./scripts/run-regressions.mjs --filter native-lorebook-import-links: 1/1 passedFails-before for the review fix: copy marinara.importer.ts aside, revert only the isGlobal guard with sed, run the regression, restore, then cmp: FAILED on 'a global book whose chats are all gone is imported as non-global' (actual true). With the isGlobal assertion also disabled temporarily, it FAILED on 'so it does not join chats it was nevernode ./scripts/run-regressions.mjs --filter lorebook: 39/39 passednode ./scripts/run-regressions.mjs --filter import: 19/19 passednode ./scripts/run-regressions.mjs --filter character: 31/31 passedIndependent adversarial review: changes, 2 issue(s), all addressed in a fix-up pass.
Known limits and risks:
Both review issues held when checked against the code and are addressed.
(1) Global plus collapsed scope. listActiveEntries runs isLorebookScopeActiveForChat first and then
if (b.isGlobal) return true(lorebooks.storage.ts:833-845). Commit3a58e678d4therefore imports a book as non-global when its specific scope collapses, with a regression case that calls listActiveEntries for an unrelated chat. Open edge case: a non-global book that keeps links to local characters but loses all of its scoped chats (only possible on the same install after those chats were deleted) becomes active in every chat with that character, where before it was hidden everywhere. I left that alone because it is the normal character-link behaviour and the finding did not cover it.(2) token_budget. characterBookSchema defaults token_budget to 512 (character.schema.ts:148), and Import Embedded now passes the card book through. A book that was never given a budget and never synced from a lorebook (character-book-sync writes the lorebook's tokenBudget back to the card) now imports, and reimports, at 512 instead of 2048. I made the text fix the reviewer called sufficient: the first What changed bullet now lists it. Keeping 2048 would mean removing the schema default or recording whether token_budget was set explicitly. That is a larger change, left for the maintainer.
Other risks carried over:
vectorizedis mirrored as !excludeFromVectorization, matching the existing Compatible World Info export.Not addressed (reviewer nits, outside the findings):
chat-request-validation times out at 90 s on this machine with and without these changes.
Not done: the user asked to make showing an outfit to a love interest in Otome Hearth give +5 affection instead of +20. That is outside this workflow step and worktree, and git grep finds no Otome Hearth outfit/affection logic in Marinara Engine. It belongs to the Otome Hearth (otome-forge) package repository, needs its own task, and must not be reported as done.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.