mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1301] [Issue]: Lorebook entry keyword logic broken — AND triggers on the first keyword alone; OR and NOT don't work #644
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#644
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 @GetBeholder on GitHub (May 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1301
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Lorebook entry keyword logic is not working. Using the in-editor keyword test, an
entry that should require all keywords (AND) is activated by the first keyword
alone, and OR and NOT logic do not work either. The keywords in the entries are
lowercase, so case sensitivity is not the variable.
Expected behavior
AND should require all configured keywords to match; OR should require any to
match; NOT should exclude the entry when matched. The in-editor keyword test
should reflect the real activation rules.
Actual behavior
AND activates the entry with just the first keyword present; OR and NOT have no
effect.
Steps to reproduce
AND.
(Keywords are lowercase in the entries.)
Impact area
Environment
Logs, screenshots, or video
The reporter attached images of the in-editor keyword test results (one for the
AND case, two more for OR/NOT). They were not provided here as files or URLs, so
they are not attached. The screenshots would clarify whether the keywords were
entered as primary or secondary keys (see triage pointer).
Regression notes
Not provided.
Additional context
Source: forum post by Era [GS] (2-Star), 5/23/26 10:21 PM, with an addendum at
10:25 PM ("OR and NOT are not working either"). The original post referenced a
title that was not included here; the subject is inferred from the content and
addendum to be lorebook keyword / selective logic (AND/OR/NOT).
Triage pointer (from a scan, not from the reporter): the pure selective-logic
helper is correct —
testSecondaryKeysinsrc/engine/shared/regex/lorebook-keyword-matching.tsimplementsand= every,or= some,not= !some. However, the scanner applies selective logic ONLY tosecondary keys, gated by
entry.selective:src/engine/generation-core/lorebooks/keyword-scanner.ts(~L459-464) callstestPrimaryKeys(entry.keys, ...)(any primary key match activates) and onlyapplies
testSecondaryKeys(entry.secondaryKeys, ..., entry.selectiveLogic, ...)when
entry.selective && entry.secondaryKeys.length > 0. Consequences:to apply across the primary keyword set, AND will appear to trigger on the first
keyword and OR/NOT will have no effect.
entry's
selectiveflag is enabled.This points at either (a) the entry editor / in-editor test not routing the user's
keywords and selective configuration to the fields the scanner actually uses
(primary vs secondary keys, the
selectiveflag), or (b) a semantics mismatchbetween what the test UI implies and the real activation rule. The maintainer
should verify the editor and the in-editor test against the scanner wiring
(L459-464) and confirm the intended semantics of selectiveLogic for primary vs
secondary keys. The reporter's screenshots would show whether the keywords were
entered as primary or secondary keys.
Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@franko-c commented on GitHub (May 27, 2026):
seems like the AND/OR/NOT logic at
LorebookEditor.tsx:636only applies to secondary keys — primary keys always match with OR (any single one triggers). ifentry.secondaryKeys.length === 0the selective check is skipped entirely regardless of the logic setting.are your keywords in the Secondary Keys field or the Primary Keys field? the UI shows the logic buttons either way but they only gate the secondary set.
@SpicyMarinara commented on GitHub (May 27, 2026):
Fixed on refactor in
8058f66dd4: lorebook secondary keyword logic now honors AND/OR/NOT whenever secondary keys exist, including older imports without the selective flag; editor preview was aligned too. Added focused Vitest coverage and ran pnpm check.