mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5416] [MERGED] Experience-state saves: player-controlled deletion, export, and import #6757
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#6757
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/5416
Author: @kolacheee
Created: 8/22/2026
Status: ✅ Merged
Merged: 8/22/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5405-save-management📝 Commits (7)
15cfcadfeat(game): add experience-save delete, export, and import verbs28726ccfix(game): harden experience-save transfer against data loss9453dc7Merge upstream/staging into feat/5405-save-management9e72860fix(game): reserve the imported: anchor prefix against forged message ids05ebf63test(game): prove the reserved-prefix refusal writes no swipe either0bdaa63Merge branch 'staging' into feat/5405-save-management86d05daMerge branch 'staging' into feat/5405-save-management📊 Changes
9 files changed (+1243 additions, -21 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/db/file-backed-store.ts(+32 -0)📝
packages/server/src/middleware/rate-limit.ts(+10 -0)📝
packages/server/src/routes/game.routes.ts(+415 -15)📝
packages/server/src/services/capability-packages/capability-persistence.service.ts(+15 -0)📝
packages/server/src/services/mari-db/mari-db.service.ts(+8 -1)📝
packages/server/src/services/storage/game-engine-state.storage.ts(+37 -5)➕
scripts/regressions/experience-state-imported-anchors.regression.ts(+164 -0)📝
scripts/regressions/experience-state.regression.ts(+561 -0)📄 Description
Linked issue
Closes #5405
Why this change
game_engine_state(#5102) with no way to delete them, export them, or bring them back — so "New Game" inherits up to 100 rows of the old campaign, and a player cannot free device space without losing a game forever. Filed from the Pixelforge S5 planning work; the package's New Game flow builds on these verbs.What changed
DELETE /api/game/:chatId/experience-state— removes the chat's experience-namespace rows ({ ok, deleted }), write-locked, count-then-delete atomic.GET /api/game/:chatId/experience-state/export— every namespace row, oldest-write-first, read under the write lock so a backup is atomic against a concurrent save; unreadable rows (unparseable text or a non-string column — the export never re-assumes the stored type) carry the samestateUnparseable: true+ cappedrawState/rawStateTruncatedshape as #5411's single-row GET, withstate: null.POST /api/game/:chatId/experience-state/import— accepts the export shape back ({ ok, imported, retained, pruned, skipped }), own bodyLimit, row-count + per-row size caps (whole-batch 422 on violation, duplicate anchors included), a flagged row with an untruncatedrawStateis restored VERBATIM (a faithful backup restores what was there — the row stays flagged on later reads); truncated captures are skipped and counted.imported:prefix so the globally-matched messages→engine-state cascade of a source chat can never destroy an imported campaign; the maintenance validator exempts the synthetic prefix from dangling-reference errors.createdAtguard (tight write loops measurably tie timestamps otherwise, and ties resolve differently in-process vs after a shard reload); checkpoint-restore clones stamp through the same helper.pruned(which counts only cap evictions — same-anchor replacements are the intended write, so a same-chat re-import reportspruned: 0), stated in the route comment, and the evicted campaign's checkpoints still restore (state captured by value).experience-stateextended (cases 14–23 after merging staging's #5407 case in as 13; case 21 pins the unreadable-row export/import round trip incl. a null-column sub-case) + newexperience-state-imported-anchorslane; all guards proven fail-first.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
experience-state+experience-state-imported-anchorslanes green with fail-first proofs per guard; adjacent lanes (game, checkpoint, chat, rate-limit, store, shard, backup, db) green;pnpm lint(typecheck ×3) green; prettier clean on touched files. Tree-wideformat:checkfalse-fails in CRLF worktrees (environmental; CI on LF is authoritative — confirmed on #5411).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.