mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2618] [Issue]: Native .marinara.json lorebook importer does not normalize numeric selectiveLogic/position (ST sibling does) #1292
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#1292
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 @Romuromylus on GitHub (Jun 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2618
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — correctness. The native
.marinara.jsonlorebook importer passesselectiveLogic(andposition) through verbatim, unlike its ST sibling which normalizes them. A foreign/hand-edited native file carrying a numericselectiveLogiclands an invalid enum value that the keyword scanner'sdefault: return truetreats as "always pass", silently disabling selective secondary-key gating (over-injection of lorebook content).Expected behavior
selectiveLogicshould be normalized to theand/or/notunion on import (numeric ST values0/1/2mapped), the same way the ST importer does, andpositionclamped to a valid value — so the keyword scanner gates correctly.Actual behavior
The sibling ST importer normalizes via
resolveSelectiveLogic()(st-lorebook.importer.ts:398, mapping0/1/2 -> and/or/not) andresolvePosition()(st-lorebook.importer.ts:380). The DB write does not enforce the enum (lorebooks.storage.ts:525writes the value with no zod parse; the Drizzle enum is type-only), and read-back (parseEntryRow) does not coerce it. At activation,keyword-scanner.ts:487→testSecondaryKeys()(packages/shared/src/utils/lorebook-keyword-matching.ts:91) has no case for a numeric value and hitsdefault: return true, so a SELECTIVE entry with secondary keys always passes instead of being gated by AND/OR/NOT. Marinara's own exporter emits the string form, so the standard round-trip is unaffected — this only bites foreign/hand-crafted native files. Fails safe (no crash, no data loss); degrades to over-permissive matching.Steps to reproduce
marinara_lorebookenvelope whoseentries[].selectiveLogicis a number (e.g.1or2) on a SELECTIVE entry that hassecondaryKeys.Environment
staging @ 56f700cd(v2.0.0)Logs, screenshots, or video
Static source audit, cited to file:line above.
Additional context
Fix sketch. Route
selectiveLogicthrough the existingresolveSelectiveLogic()normalizer inmarinara.importer.ts:479(the same onest-lorebook.importer.ts:398uses), and routepositionthroughresolvePosition()atmarinara.importer.ts:494to clamp non-numeric values to0-2. Fix-pattern-already-in-repo: the ST importer is the reference implementation.Regression notes. Not a regression —
main'smarinara.importer.tshas the byte-identicalselectiveLogicandpositionlines. Long-standing on both branches. Distinct from #2530 (the ST importer role allowlist — different field, different importer).Template check
@Romuromylus commented on GitHub (Jun 18, 2026):
Fixed in #2623, merged to
staging(e1132e5b). Closing manually since the PR targetedstagingrather than the default branch.