mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2474] [Issue]: Prompt-only regex scripts are applied in storage order instead of the user-configured order #1217
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#1217
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 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2474
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Severity: Low — correctness regression. Prompt-only regex scripts are applied to the outgoing prompt in storage/file order, not the user-configured
sortOrder, so when multiple overlapping prompt-only scripts compose, the result differs from what the user arranged (and from main, which applies them in order).Expected behavior
Apply prompt-only regex scripts in the user-defined order (
sortOrder), matching main'sorderBy(asc(order))and the refactor's own runtime/display path which already sorts.Actual behavior
Both prompt-assembly call sites list the scripts with no sort:
applyRegexScriptsToPromptText(regex-application.ts) iteratesscriptsin array order and mutates the result cumulatively, so the composition of overlapping prompt-only scripts is order-dependent. The genericstorage.listreturns insertion/file order. This is inconsistent with the refactor's own runtime pathregex-runtime.ts:27((await storage.list("regex-scripts")).sort(bySortOrder)) and with every sibling collection inprompt-assembly.ts(sections/groups/choiceBlocks all use.sort(bySortOrder)).bySortOrderis already imported in this file.Steps to reproduce
sortOrder/order).Impact area
Environment
1fae2c42Logs, screenshots, or video
Static trace:
prompt-assembly.ts:3614and:3625(no sort);regex-application.tsarray-order apply; contrastregex-runtime.ts:27which sorts.Regression notes
Regression vs main, which applies regex scripts by
asc(order). Note: #2454 ("Fix prompt regex coverage", closing #2449) recently touched this exact code to fix the prompt/injection coverage gap, but it added no sort — the ordering defect is separate and untouched. Distinct from #2449 (coverage) and #2450 (regenerate source prompt).Additional context
Fix is a one-liner:
const regexScripts = (await storage.list<JsonRecord>("regex-scripts")).sort(bySortOrder);at both call sites, matchingregex-runtime.ts. Low severity: requires ≥2 overlapping prompt-only scripts plus a reorder that diverges from insertion order; non-destructive output drift.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 6, 2026):
Fixed on refactor in
038b7220.Prompt-only regex scripts are sorted by the configured sort order before prompt application.
Verification: pnpm typecheck; pnpm build; pnpm check:architecture; cargo check --manifest-path src-tauri/Cargo.toml --workspace; focused Rust backup/profile tests; git diff --check; no .test.ts/.test.tsx files present.