mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2975] [Issue]: Ephemeral activation counter is decremented on sticky carry-over, auto-disabling entries after a single real trigger #1550
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#1550
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 (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2975
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
An entry that uses both
ephemeral(activations remaining before auto-disable) andsticky(stay active for N messages after a trigger) burns an ephemeral charge on every turn it is kept alive by sticky, even though no fresh keyword match occurred. The timing subsystem deliberately treats sticky carry-over as not a real activation, but the ephemeral countdown does not. Result: an entry configured for, say, 2 ephemeral activations withsticky = 5is disabled after a single real trigger (the sticky tail eats the remaining charge), so it never fires again on a later genuine keyword match in that chat.How to reproduce (try it yourself)
keys = ["dragon"],ephemeral = 2,sticky = 5, in a chat (a chatId is present so per-chat overrides are tracked).You'll see: ephemeral decrements 1→0 and the entry is written
enabled:falsefor this chat. A later real "dragon" mention does not re-activate it.Expected: sticky carry-over does not consume an ephemeral charge; the entry retains its second allotted activation.
Where it is
packages/server/src/services/lorebook/index.ts:975-984(per-chat overrides block) and:988-996(legacy chatId block) — both decrement onif (a.entry.ephemeral !== null && a.entry.ephemeral > 0)with no!a.stickyguard.sticky: trueandmatchedKeys: ["[sticky]"]atpackages/server/src/services/lorebook/keyword-scanner.ts:475-484.packages/server/src/services/lorebook/keyword-scanner.ts:257gates the fresh-activation branch on!activated.sticky.What's happening
The ephemeral decrement loop iterates
finalActivatedand decrements any entry withephemeral > 0unconditionally, without skipping entries whose activation came from sticky carry-over (a.sticky === true). This contradictsupdateTimingStatesForScan, which already establishes that sticky carry-over is not a new activation. Sinceephemeralmeans "activations remaining", sticky carry-overs should not consume a charge.Suggested fix
Guard the ephemeral decrement on a non-sticky activation, mirroring the timing logic — change the condition to
if (!a.sticky && a.entry.ephemeral !== null && a.entry.ephemeral > 0)in both the overrides block (:975-984) and the legacy chatId block (:988-996). Only[sticky]carry-overs seta.sticky === true, so fresh keyword and constant activations still decrement as before.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in the v2.0.7 branch: sticky carry-over activations no longer decrement ephemeral counters; only fresh activations spend the ephemeral budget. Validated with pnpm check and pnpm regression:prompt.