mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #6134] The lorebook entry search endpoint only matches entry names, even though it says it searches content and keys too #3411
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#3411
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 @kolacheee on GitHub (Sep 13, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6134
Originally assigned to: @SpicyMarinara on GitHub.
The server has a lorebook entry search endpoint that its own note describes as searching an entry's name, content, and keys. It only ever looks at the name. A search for a word that appears only in an entry's text, or only in one of its keys, comes back empty.
Nothing in the app calls this endpoint any more, so no one is losing search results today. It matters because the Pixelforge roadmap in the Marinara-Agents repo points future work at this endpoint as a ready-made search, and describes it as doing more than it does.
How to reproduce (try it yourself)
ProbeBookand save.ProbeBook, click Add Entry, and fill it in exactly: NameZebraName, Contentthe secret word is QUOKKAWORD here, and one KeyARMADILLOKEY. Save the entry.await (await fetch('/api/lorebooks/search/entries?q=ZebraName')).json()await (await fetch('/api/lorebooks/search/entries?q=QUOKKAWORD')).json()await (await fetch('/api/lorebooks/search/entries?q=ARMADILLOKEY')).json()What you'll see: the first query returns a one-item list with the entry. The second returns
[], even though QUOKKAWORD is in the entry's content. The third returns[], even though ARMADILLOKEY is one of its keys. (The name match is case-insensitive, so?q=zebraalso returns the entry - that confirms the endpoint is alive and it really is the name-only match producing the empty results.)What should happen: all three return the entry, because the method's own note says it searches name, content, and keys.
Where it is
At staging
52799569c:packages/server/src/services/storage/lorebooks.storage.ts:1359- the note:/** Search entries by keyword match in name/content/keys. */packages/server/src/services/storage/lorebooks.storage.ts:1365- the entire matching condition insearchEntries(query):.where(like(lorebookEntries.name, pattern))packages/server/src/routes/lorebooks.routes.ts:846-850-app.get("/search/entries", ...)callingstorage.searchEntries(query), registered under/api/lorebooksWhat's happening
The database query has one condition and it only looks at the name column. Content and keys are never consulted. The note above it has said name/content/keys since the repository's first commit (
8038e96c1), so this is not a behaviour that was narrowed later - the note described an intention that was never implemented.The endpoint is also dead code. The client hook that used to call it,
useSearchLorebookEntries, was removed frompackages/client/src/hooks/use-lorebooks.tsin232aae8af(2026-07-22, "Clean up unused code and dependencies") and nothing replaced it. At staging the only mentions ofsearchEntriesorsearch/entriesanywhere in the Engine are the route itself and the storage method. The lorebook search boxes people actually see search whole books throughGET /api/lorebooks?search=, a different path. The GM'ssearch_lorebooktool is also a different path (tool-executor.ts:330goes tocontext.searchLorebook, which does match name, content, and keys), so no chat or GM session is missing results because of this.Suggested fix
Make one decision and apply it in one pass. The cheaper option looks like the right one: delete the
/search/entriesroute and thesearchEntriesstorage method, since nothing has called them in almost two months, and fix the stale pointer in the other repo at the same time -packages/pixelforge/docs/ROADMAP.md:581in Marinara-Agents tells a future implementer not to build search because it "already exists in the Engine" at this URL "with calibrated-cosine ranking behind it." Neither half is true of this endpoint: there is no ranking at all, it orders by the entry'sorderfield. That line should point at the GM lorebook search path instead.If the endpoint is kept instead, widen the condition to name OR content OR keys and leave the note as it is. Keys are stored as a serialized JSON array, so that needs a deliberate matching strategy rather than a plain text match over the raw JSON, or searches will start hitting brackets and quote characters.
Context
Issue #5955 named this exact file and line range as an "adjacent, smaller" item deliberately left out of scope; PR #5982 delivered that issue's actual ask (semantic GM lorebook search) and #5955 closed on 2026-09-09 with this part untouched and no open issue tracking it. The behaviour is not a recent regression and is present in the latest release v2.4.4 - it dates to the repository's initial import.
Found by an AI-assisted sweep of merged PR #5982 against issue #5955, then re-verified against staging
52799569con 2026-09-13. Please verify before fixing.@SpicyMarinara commented on GitHub (Sep 13, 2026):
@SpicyMarinara is taking this report through the issue sweep in draft PR #6137, with Codex assisting. The affected current-code path has been checked; implementation and focused regression verification are in progress.
@SpicyMarinara commented on GitHub (Sep 13, 2026):
Fixed in #6137, now merged to staging (
e044997a2). The lore entry search endpoint matches names, content, and parsed keys literally and case-insensitively.