mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2423] [MERGED] Guard debounced manual world-state patch against stale chat.gameState write #5599
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#5599
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2423
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/world-state-stale-target-guard📝 Commits (1)
39c59b1Guard debounced manual world-state patch against stale chat.gameState write📊 Changes
1 file changed (+30 additions, -1 deletions)
View changed files
📝
src/features/runtime/world-state/api/world-state-api.ts(+30 -1)📄 Description
Linked issue
Closes #2327
Why this change
chat.gameState, clobbering the current turn's persisted state (notably breaksgameStateCarryoverPatchseeding a new session).What changed
src/features/runtime/world-state/api/world-state-api.ts: thechat.gameStatewrite inworldStateApi.patchis now gated by a newcanPersistChatGameStatehelper. Patches without an explicitrequestedTarget(per-turn snapshot writes,clearManualState) still always write. A patch that pinned a specific target (debounced manual edits) re-resolves the current visible assistant target at flush time and only writeschat.gameStatewhen the pinned target is still visible; otherwise it keeps the per-message snapshot and lets the visible-read path ownchat.gameState.trackerSnapshotApi.savestays unconditional. Fail-open on error preserves current behavior.Refactor impact
Primary owner: world-state
Impact areas reviewed:
src/features/runtime/world-state/api/world-state-api.ts(patch, newcanPersistChatGameState)Boundary notes:
latestAssistantTarget(onelistChatMessages) call only on the low-frequency manual-edit path; the per-turn hot path returns immediately. No Rust/DB/schema change.Pressure points touched:
Validation
pnpm checkpasses before PR push/handoffManual verification notes
pnpm vitest run(world-state-api) — a local-only test drove the race: a stalerequestedTarget(pinnedmsg-OLD, visible advanced tomsg-NEW) saves the per-message snapshot but performs ZEROstorageApi.update("chats", …)writes; a still-visible target writeschat.gameStateonce; both no-requestedTargetpaths still write (no per-turn regression).pnpm exec tsc -b— clean (with and without the local test).Feature Discoverability
src/features/shell/discovery/Reason:
Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.