mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2199] [Issue]: Lorebook regex safety no longer has a hard execution timeout #1098
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#1098
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 @Promansis on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2199
Originally assigned to: @Promansis on GitHub.
Summary
The Batch 7 lorebook parityscan found that refactor no longer preserves legacy hard-timeout behavior for user-supplied lorebook regex keyword matching. Legacy ran regex tests in a VM with a timeout; refactor uses static safety heuristics and a scan-text length cap, but no interruptible execution timeout.
Expected behavior
Lorebook regex keyword matching should fail closed when a user-supplied regex becomes too expensive to execute, without hanging generation or preview scans. If the refactor intentionally replaces the legacy hard timeout with static checks plus a text cap, that divergence should be documented and backed by focused proof.
Actual behavior
Refactor rejects many risky patterns with
isPatternSafeand skips regex execution for scan text over 100,000 characters, but accepted patterns still run through normal JavaScriptRegExp.testwithout a hard execution timeout. Legacy had a second line of defense: VM execution with a per-call timeout.Steps to reproduce
src/engine/generation-core/lorebooks/regex-timeout.tsreturns false for unsafe patterns or oversized scan text, then runsnew RegExp(regex.source, flags).test(text)directly for accepted patterns.main, wherepackages/server/src/services/lorebook/regex-timeout.tsranRegExp.testthroughvm.runInContextwith a timeout.Impact area
Environment
refactor/577de008Logs, screenshots, or video
Static trace:
src/engine/shared/regex/regex-safety.ts.src/engine/generation-core/lorebooks/regex-timeout.ts.vmRegexExecutorinto regex matching:src/engine/generation-core/lorebooks/keyword-scanner.ts.packages/server/src/services/lorebook/regex-timeout.tsonmain.No live hang repro was run in this scan.
Regression notes
Legacy
mainused a hard VM timeout as a second line of defense after static regex safety checks. Refactor preserved static checks but does not preserve the hard timeout behavior.Additional context
Parity target: #2181
Parity row:
07-LB-ERROR-regex-safetyClassification from Batch 7 scan:
Legacy better/Current refactor risk.Suggested next action: either add an interruptible regex execution strategy appropriate for the refactor runtime, or explicitly document/prove the static safety + scan-size cap as an intentional divergence.
Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: